Skip to content

Commit 4b42383

Browse files
committed
core/connpool: exit early from infinite for-loop if pool closed
1 parent 9539876 commit 4b42383

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

intra/core/connpool.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,11 @@ func (c *ConnPool[T]) clean() {
223223
}
224224

225225
func (c *ConnPool[T]) scrub() {
226-
if c.closed.Load() {
227-
return
228-
}
229226
for {
227+
if c.closed.Load() {
228+
return
229+
}
230+
230231
select {
231232
case conn := <-c.p:
232233
if readable(conn) {
@@ -242,6 +243,7 @@ func (c *ConnPool[T]) scrub() {
242243
clos(conn)
243244
}
244245
case <-c.ctx.Done():
246+
return
245247
default:
246248
return
247249
}

0 commit comments

Comments
 (0)