Browse Source

Fix node_timer bug; sometimes was not initializing watcher

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
b571900d9c
  1. 6
      src/node_timer.cc
  2. 5
      src/node_timer.h

6
src/node_timer.cc

@ -149,8 +149,10 @@ Handle<Value> Timer::Again(const Arguments& args) {
int was_active = ev_is_active(&timer->watcher_);
ev_tstamp repeat = NODE_V8_UNIXTIME(args[0]);
if (repeat > 0) timer->watcher_.repeat = repeat;
if (args.Length() > 0) {
ev_tstamp repeat = NODE_V8_UNIXTIME(args[0]);
if (repeat > 0) timer->watcher_.repeat = repeat;
}
ev_timer_again(EV_DEFAULT_UC_ &timer->watcher_);

5
src/node_timer.h

@ -15,7 +15,10 @@ class Timer : ObjectWrap {
protected:
static v8::Persistent<v8::FunctionTemplate> constructor_template;
Timer () : ObjectWrap () { }
Timer () : ObjectWrap () {
// dummy timeout values
ev_timer_init(&watcher_, OnTimeout, 0., 1.);
}
~Timer();
static v8::Handle<v8::Value> New (const v8::Arguments& args);

Loading…
Cancel
Save