Fix bug in timers_uv timeout recomputation
authorBert Belder <bertbelder@gmail.com>
Mon, 4 Jul 2011 23:31:00 +0000 (01:31 +0200)
committerBert Belder <bertbelder@gmail.com>
Mon, 4 Jul 2011 23:31:23 +0000 (01:31 +0200)
Closes #1209

lib/timers_uv.js

index 2c37787..59b016e 100644 (file)
@@ -67,8 +67,7 @@ function insert(item, msecs) {
 
     list.ontimeout = function() {
       debug('timeout callback ' + msecs);
-      // TODO - don't stop and start the watcher all the time.
-      // just set its repeat
+
       var now = new Date();
       debug('now: ' + now);
 
@@ -76,7 +75,7 @@ function insert(item, msecs) {
       while (first = L.peek(list)) {
         var diff = now - first._idleStart;
         if (diff + 1 < msecs) {
-          list.start(diff, 0);
+          list.start(msecs - diff, 0);
           debug(msecs + ' list wait because diff is ' + diff);
           return;
         } else {