panic when unbalanced localState.Resume() is detected
This commit is contained in:
parent
4cd1b09ad7
commit
9a1b52171f
|
@ -114,7 +114,10 @@ func (l *localState) Pause() {
|
|||
|
||||
// Resume is used to resume state synchronization
|
||||
func (l *localState) Resume() {
|
||||
atomic.AddInt32(&l.paused, -1)
|
||||
paused := atomic.AddInt32(&l.paused, -1)
|
||||
if paused < 0 {
|
||||
panic("unbalanced localState.Resume() detected")
|
||||
}
|
||||
l.changeMade()
|
||||
}
|
||||
|
||||
|
|
|
@ -685,6 +685,15 @@ func TestAgent_nestedPauseResume(t *testing.T) {
|
|||
if l.isPaused() != false {
|
||||
t.Fatal("localState should NOT be Paused after SECOND call to Resume()")
|
||||
}
|
||||
|
||||
defer func() {
|
||||
err := recover()
|
||||
if err == nil {
|
||||
t.Fatal("unbalanced Resume() should cause a panic()")
|
||||
}
|
||||
}()
|
||||
l.Resume()
|
||||
|
||||
}
|
||||
|
||||
var testRegisterRules = `
|
||||
|
|
Loading…
Reference in New Issue