Commit e96fd132 authored by Ian Lance Taylor's avatar Ian Lance Taylor

runtime: use correct state machine in addAdjustedTimers

The addAdjustedTimers function was a late addition, and it got some of
the state machine wrong, leading to failures like
https://storage.googleapis.com/go-build-log/930576b6/windows-amd64-2016_53d0319e.log

Updates #6239
Updates #27707

Change-Id: I9e94e563b4698ff3035ce609055ca292b9cab3df
Reviewed-on: https://go-review.googlesource.com/c/go/+/204280
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: default avatarMichael Knyszek <mknyszek@google.com>
parent efd395f9
......@@ -989,10 +989,12 @@ func addAdjustedTimers(pp *p, moved []*timer) {
case timerDeleted:
// Timer has been deleted since we adjusted it.
// This timer is already out of the heap.
if !atomic.Cas(&t.status, s, timerRemoved) {
if atomic.Cas(&t.status, s, timerRemoving) {
if !atomic.Cas(&t.status, timerRemoving, timerRemoved) {
badTimer()
}
break loop
}
case timerModifiedEarlier, timerModifiedLater:
// Timer has been modified again since
// we adjusted it.
......@@ -1007,8 +1009,8 @@ func addAdjustedTimers(pp *p, moved []*timer) {
if s == timerModifiedEarlier {
atomic.Xadd(&pp.adjustTimers, -1)
}
}
break loop
}
case timerNoStatus, timerRunning, timerRemoving, timerRemoved, timerMoving:
badTimer()
case timerModifying:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment