Replace IsAlive with IsClosed
IsAlive is ambiguous because the connection may be dead and we do not know it. It implies the possibility of a ping. IsClosed is clearer -- it does not promise the connection is alive only that it hasn't been closed.
This commit is contained in:
+1
-1
@@ -27,7 +27,7 @@ func (c *Conn) Release() {
|
||||
c.res = nil
|
||||
|
||||
now := time.Now()
|
||||
if !conn.IsAlive() || conn.PgConn().TxStatus != 'I' || (now.Sub(res.CreationTime()) > c.p.maxConnLifetime) {
|
||||
if conn.IsClosed() || conn.PgConn().TxStatus != 'I' || (now.Sub(res.CreationTime()) > c.p.maxConnLifetime) {
|
||||
res.Destroy()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user