Jelajahi Sumber

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

lock mu when checking if the pool is closed
Ben Hood 10 tahun lalu
induk
melakukan
45986ad840
1 mengubah file dengan 4 tambahan dan 1 penghapusan
  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.
 	}
 }