Merge pull request #48 from anyproto/fix-open-requests
Fix openingWaitCount logic
This commit is contained in:
commit
7049a884a7
@ -106,10 +106,10 @@ func (p *peer) AcquireDrpcConn(ctx context.Context) (drpc.Conn, error) {
|
|||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
if len(p.inactive) == 0 {
|
if len(p.inactive) == 0 {
|
||||||
wait := p.limiter.wait(len(p.active) + int(p.openingWaitCount.Load()))
|
wait := p.limiter.wait(len(p.active) + int(p.openingWaitCount.Load()))
|
||||||
|
p.openingWaitCount.Add(1)
|
||||||
|
defer p.openingWaitCount.Add(-1)
|
||||||
p.mu.Unlock()
|
p.mu.Unlock()
|
||||||
if wait != nil {
|
if wait != nil {
|
||||||
p.openingWaitCount.Add(1)
|
|
||||||
defer p.openingWaitCount.Add(-1)
|
|
||||||
// throttle new connection opening
|
// throttle new connection opening
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user