]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: don't skip timer when adjustTimers sees a modified timer
authorIan Lance Taylor <iant@golang.org>
Fri, 10 Jan 2020 18:10:32 +0000 (10:10 -0800)
committerIan Lance Taylor <iant@golang.org>
Fri, 10 Jan 2020 19:19:22 +0000 (19:19 +0000)
When adjustTimers sees a timerModifiedEarlier or timerModifiedLater,
it removes it from the heap, leaving a new timer at that position
in the heap. We were accidentally skipping that new timer in our loop.
In some unlikely cases this could cause adjustTimers to look at more
timers than necessary.

Change-Id: Ic71e54c175ab7d86a7fa46f1497aca71ed1c43cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/214338
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/time.go

index d64bea814fd82a8e84f399a955bf76d2fd1aefb5..e0dfd6a5cd35e56758319d3833f421ce81399ce9 100644 (file)
@@ -669,6 +669,8 @@ func adjusttimers(pp *p) {
                                                return
                                        }
                                }
+                               // Look at this heap position again.
+                               i--
                        }
                case timerNoStatus, timerRunning, timerRemoving, timerRemoved, timerMoving:
                        badTimer()