Fix node_timer bug; sometimes was not initializing watcher

This commit is contained in:
Ryan Dahl 2010-03-12 12:55:34 -08:00
parent c857d65dd3
commit b571900d9c
2 changed files with 8 additions and 3 deletions

View File

@ -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_);

View File

@ -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);