Skip to content

Commit

Permalink
Merge pull request #257 from glutamatt/fix-connection-picker
Browse files Browse the repository at this point in the history
Fix ErrNoConnections from defaultConnectionPicker.Remove code
  • Loading branch information
dkropachev authored Sep 9, 2024
2 parents 3a1e987 + 7e33298 commit bed2d7e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions connectionpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,4 +551,5 @@ func (pool *hostConnPool) HandleError(conn *Conn, err error, closed bool) {
}

pool.connPicker.Remove(conn)
go pool.fill()
}
5 changes: 3 additions & 2 deletions connpicker.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ func (p *defaultConnPicker) Remove(conn *Conn) {

for i, candidate := range p.conns {
if candidate == conn {
p.conns[i] = nil
return
last := len(p.conns) - 1
p.conns[i], p.conns = p.conns[last], p.conns[:last]
break
}
}
}
Expand Down

0 comments on commit bed2d7e

Please sign in to comment.