changeset 132:61f86d069259

Dont close db connections if they are currently busy when garbage collecting idle db connections.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 28 Jun 2018 17:18:29 +0200
parents af114cf64822
children f4523620ba5d
files auth/connection.go
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/auth/connection.go	Thu Jun 28 17:13:02 2018 +0200
+++ b/auth/connection.go	Thu Jun 28 17:18:29 2018 +0200
@@ -70,9 +70,8 @@
 func (cp *ConnectionPool) cleanDB() {
 	valid := time.Now().Add(-maxDBIdle)
 	for _, con := range cp.conns {
-		if con.access.Before(valid) && con.db != nil {
-			con.db.Close()
-			con.db = nil
+		if con.refCount <= 0 && con.access.Before(valid) {
+			con.close()
 		}
 	}
 }