Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update libev's clock when starting timers

Make the timeouts more accurate. See test/pummel/test-timers.js
  • Loading branch information...
commit ec0266a56cca10c5faa92c54baf2d3bb447ece65 1 parent b72ffc0
@ry ry authored
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/node_timer.cc
View
5 src/node_timer.cc
@@ -120,6 +120,11 @@ Timer::Start (const Arguments& args)
ev_tstamp repeat = NODE_V8_UNIXTIME(args[1]);
ev_timer_init(&timer->watcher_, Timer::OnTimeout, after, repeat);
timer->watcher_.data = timer;
+
+ // Update the event loop time. Need to call this because processing JS can
+ // take non-negligible amounts of time.
+ ev_now_update(EV_DEFAULT_UC);
+
ev_timer_start(EV_DEFAULT_UC_ &timer->watcher_);
if (!was_active) timer->Ref();
Please sign in to comment.
Something went wrong with that request. Please try again.