]> Cypherpunks repositories - gostls13.git/commitdiff
fix bug in tick
authorRob Pike <r@golang.org>
Fri, 29 Jan 2010 21:10:33 +0000 (13:10 -0800)
committerRob Pike <r@golang.org>
Fri, 29 Jan 2010 21:10:33 +0000 (13:10 -0800)
Fixes #576.

R=rsc, rog
CC=golang-dev
https://golang.org/cl/196061

src/pkg/time/tick.go

index db3f68776b678157ed72cfe1148013340349c15c..bbbc469618f6d64b39fac9a103faf977e9aba1e7 100644 (file)
@@ -47,6 +47,7 @@ func (a *alarmer) set(ns int64) {
                }
                a.wakeMeAt = make(chan int64, 10)
                go wakeLoop(a.wakeMeAt, a.wakeUp)
+               a.wakeTime = ns
                a.wakeMeAt <- ns
        }
 }
@@ -117,7 +118,7 @@ func tickerLoop() {
                                        }
                                        continue
                                }
-                               if tickers.nextTick <= now {
+                               if t.nextTick <= now {
                                        if len(t.c) == 0 {
                                                // Only send if there's room.  We must not block.
                                                // The channel is allocated with a one-element
@@ -130,9 +131,9 @@ func tickerLoop() {
                                                // Still behind; advance in one big step.
                                                t.nextTick += (now - t.nextTick + t.ns) / t.ns * t.ns
                                        }
-                                       if t.nextTick > now && t.nextTick < wakeTime {
-                                               wakeTime = t.nextTick
-                                       }
+                               }
+                               if t.nextTick < wakeTime {
+                                       wakeTime = t.nextTick
                                }
                                prev = t
                        }