mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-15 16:07:51 +03:00
Fix the MaxConns semaphore issue in HostClient. (#1831)
Fix the MaxConns semaphore issue in HostClient. Currently, the conns length and connsCount count in HostClient do not correctly implement the MaxConns semaphore mechanism. This fix ensures that the waiter wake-up chain does not break.
This commit is contained in:
@@ -1749,7 +1749,17 @@ func (c *HostClient) releaseConn(cc *clientConn) {
|
||||
w := q.popFront()
|
||||
if w.waiting() {
|
||||
delivered = w.tryDeliver(cc, nil)
|
||||
break
|
||||
// This is the last resort to hand over conCount sema.
|
||||
// We must ensure that there are no valid waiters in connsWait
|
||||
// when we exit this loop.
|
||||
//
|
||||
// We did not apply the same looping pattern in the decConnsCount
|
||||
// method because it needs to create a new time-spent connection,
|
||||
// and the decConnsCount call chain will inevitably reach this point.
|
||||
// When MaxConnWaitTimeout>0.
|
||||
if delivered {
|
||||
break
|
||||
}
|
||||
}
|
||||
c.connsWait.failedWaiters.Add(-1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user