stop timer

This commit is contained in:
foxyriver 2017-11-06 09:51:39 +08:00
parent 210626577b
commit cdc4aca9a3
2 changed files with 2 additions and 0 deletions

View File

@ -104,6 +104,7 @@ func (a *poller) bootstrapping() {
// bootstrapGracePeriod is read-only, so no lock is required
timer := time.NewTimer(a.bootstrapGracePeriod)
go func() {
defer timer.Stop()
<-timer.C
a.lock.Lock()
defer a.lock.Unlock()

View File

@ -50,6 +50,7 @@ func TestTolerateBootstrapFailure(t *testing.T) {
go func() {
// The test might have false negative, but won't be flaky
timer := time.NewTimer(2 * time.Second)
defer timer.Stop()
<-timer.C
fakeGetSucceedLock.Lock()
defer fakeGetSucceedLock.Unlock()