Skip to content

Commit 69217a5

Browse files
authored
dev: no semaphore if canceled (#6128)
1 parent 870ddc1 commit 69217a5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pkg/goanalysis/runner_loadingpackage.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,13 @@ func (lp *loadingPackage) analyzeRecursive(ctx context.Context, cancel context.C
6363
}
6464

6565
func (lp *loadingPackage) analyze(ctx context.Context, cancel context.CancelFunc, loadMode LoadMode, loadSem chan struct{}) {
66-
loadSem <- struct{}{}
67-
defer func() {
68-
<-loadSem
69-
}()
70-
7166
select {
7267
case <-ctx.Done():
7368
return
74-
default:
69+
case loadSem <- struct{}{}:
70+
defer func() {
71+
<-loadSem
72+
}()
7573
}
7674

7775
// Save memory on unused more fields.

0 commit comments

Comments
 (0)