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
|
// Resume is used to resume state synchronization
|
||||||
func (l *localState) Resume() {
|
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()
|
l.changeMade()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -685,6 +685,15 @@ func TestAgent_nestedPauseResume(t *testing.T) {
|
||||||
if l.isPaused() != false {
|
if l.isPaused() != false {
|
||||||
t.Fatal("localState should NOT be Paused after SECOND call to Resume()")
|
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 = `
|
var testRegisterRules = `
|
||||||
|
|
Loading…
Reference in New Issue