Skip to content

Commit

Permalink
Merge pull request #100 from bgokden/develop
Browse files Browse the repository at this point in the history
Avoid infinite loop in connection close
  • Loading branch information
bgokden authored Aug 10, 2021
2 parents ec1e024 + 94e21c8 commit 66937aa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion util/connpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (cp *ConnectionPool) Close(conn *Connection) {

func (cp *ConnectionPool) CloseAll() {
cp.Closed = true
for {
for i := 0; i < 1000; i++ { // Maximum 1000 connections will be closed
connectionInterface := cp.Pool.Get()
if connectionInterface == nil {
return // Coonection pool is finished
Expand All @@ -197,6 +197,8 @@ func (cp *ConnectionPool) CloseAll() {
log.Printf("Connection Close Error: %v\n", err.Error())
}
}
} else {
return
}
}
}

0 comments on commit 66937aa

Please sign in to comment.