Skip to content

Commit

Permalink
ep refresher finish chan add close protection
Browse files Browse the repository at this point in the history
  • Loading branch information
liangwei3 committed Apr 8, 2024
1 parent 1f620a4 commit 3115d01
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lb/weightedEpRefresher.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,17 @@ func refreshDynamicWeight(holders []*WeightedEpHolder, taskTimeout int64) bool {
defer close(finishChan)
go func() {
wg.Wait()
finishChan <- struct{}{}
// the chan might be closed
select {
case _, ok := <-finishChan:
if !ok {
// chan has been closed
return
}
default:
finishChan <- struct{}{}
return
}
}()
select {
case <-timer.C:
Expand Down

0 comments on commit 3115d01

Please sign in to comment.