Browse Source

Don't try closing something that doesn't exist

Fixes #27
Matt Robenolt 12 years ago
parent
commit
776c8a6e60
1 changed files with 3 additions and 0 deletions
  1. 3 0
      gocql.go

+ 3 - 0
gocql.go

@@ -204,6 +204,9 @@ func (cn *connection) open() {
 // close a connection actively, typically used when there's an error and we want to ensure
 // close a connection actively, typically used when there's an error and we want to ensure
 // we don't repeatedly try to use the broken connection
 // we don't repeatedly try to use the broken connection
 func (cn *connection) close() {
 func (cn *connection) close() {
+	if cn.c == nil {
+		return
+	}
 	cn.c.Close()
 	cn.c.Close()
 	cn.c = nil // ensure we generate ErrBadConn when cn gets reused
 	cn.c = nil // ensure we generate ErrBadConn when cn gets reused
 	cn.alive = false
 	cn.alive = false