Skip to content

Commit

Permalink
fix: not wait for MaxHoldTime if AlwaysHold is true
Browse files Browse the repository at this point in the history
  • Loading branch information
hsldymq committed Jan 30, 2024
1 parent b637607 commit 11fd20d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
vendor/
vendor/
.idea/
13 changes: 7 additions & 6 deletions keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,13 @@ func (k *ShutdownKeeper) Wait() {
}
<-k.shutdownEventChan

if !k.alwaysHold && k.getHoldTokenNum() == 0 {
return
}
select {
case <-time.After(k.maxHoldTime):
case <-k.tokenReleaseChan:
if k.alwaysHold {
<-time.After(k.maxHoldTime)
} else if k.getHoldTokenNum() > 0 {
select {
case <-time.After(k.maxHoldTime):
case <-k.tokenReleaseChan:
}
}
}

Expand Down

0 comments on commit 11fd20d

Please sign in to comment.