Skip to content

Commit 66937aa

Browse files
authored
Merge pull request #100 from bgokden/develop
Avoid infinite loop in connection close
2 parents ec1e024 + 94e21c8 commit 66937aa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

util/connpool.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func (cp *ConnectionPool) Close(conn *Connection) {
185185

186186
func (cp *ConnectionPool) CloseAll() {
187187
cp.Closed = true
188-
for {
188+
for i := 0; i < 1000; i++ { // Maximum 1000 connections will be closed
189189
connectionInterface := cp.Pool.Get()
190190
if connectionInterface == nil {
191191
return // Coonection pool is finished
@@ -197,6 +197,8 @@ func (cp *ConnectionPool) CloseAll() {
197197
log.Printf("Connection Close Error: %v\n", err.Error())
198198
}
199199
}
200+
} else {
201+
return
200202
}
201203
}
202204
}

0 commit comments

Comments
 (0)