Browse Source

Use defer to unlock in session.go

Chris Bannister 11 years ago
parent
commit
09e353bbec
1 changed files with 1 additions and 2 deletions
  1. 1 2
      session.go

+ 1 - 2
session.go

@@ -92,12 +92,11 @@ func (s *Session) Query(stmt string, values ...interface{}) *Query {
 // operation.
 func (s *Session) Close() {
 	s.closeMu.Lock()
+	defer s.closeMu.Unlock()
 	if s.isClosed {
-		s.closeMu.Unlock()
 		return
 	}
 	s.isClosed = true
-	s.closeMu.Unlock()
 
 	s.Node.Close()
 }