Skip to content

Commit f453fb3

Browse files
committed
fix potential blocking
1 parent e6d7036 commit f453fb3

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

internal/worker/concurrency.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"context"
2525
"fmt"
2626
"sync"
27-
"time"
2827

2928
"github.com/marusama/semaphore/v2"
3029
)
@@ -77,7 +76,7 @@ func (p *permit) AcquireChan(ctx context.Context, wg *sync.WaitGroup) <-chan str
7776
}
7877
select { // try to send to channel, but don't block if listener is gone
7978
case ch <- struct{}{}:
80-
case <-time.After(10 * time.Millisecond): // wait time is needed to avoid race condition of channel sending
79+
case <-ctx.Done():
8180
p.sem.Release(1)
8281
}
8382
}()

0 commit comments

Comments
 (0)