agent: fix missed-wakeup race in WaitChange
notifyChange must hold changeMu when broadcasting. Without the lock, the broadcast can fire between the consumer's value check and its cond.Wait call — the signal is lost and the consumer sleeps until the next change, causing an apparent off-by-one lag. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fdc77618ab
commit
f03ccadd43
|
|
@ -328,7 +328,9 @@ func (s *agentCore) State() string {
|
|||
}
|
||||
|
||||
func (s *agentCore) notifyChange() {
|
||||
s.changeMu.Lock()
|
||||
s.changeCond.Broadcast()
|
||||
s.changeMu.Unlock()
|
||||
}
|
||||
|
||||
// WaitChange blocks until the named field changes from current, then returns
|
||||
|
|
|
|||
Reference in New Issue