Explorar o código

Merge pull request #319 from Zariel/fix-data-race

lock mu when checking if the pool is closed
Ben Hood %!s(int64=10) %!d(string=hai) anos
pai
achega
45986ad840
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      connectionpool.go

+ 4 - 1
connectionpool.go

@@ -291,7 +291,10 @@ func (c *SimplePool) HandleError(conn *Conn, err error, closed bool) {
 		return
 	}
 	c.removeConn(conn)
-	if !c.quit {
+	c.mu.Lock()
+	poolClosed := c.quit
+	c.mu.Unlock()
+	if !poolClosed {
 		go c.fillPool() // top off pool.
 	}
 }