mirror of
https://github.com/status-im/consul.git
synced 2025-01-23 03:59:18 +00:00
panic when unbalanced localState.Resume() is detected
This commit is contained in:
parent
b014c0f91b
commit
c4537ed26f
@ -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…
x
Reference in New Issue
Block a user