Skip to content

Commit b571900

Browse files
committed
Fix node_timer bug; sometimes was not initializing watcher
1 parent c857d65 commit b571900

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/node_timer.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ Handle<Value> Timer::Again(const Arguments& args) {
149149

150150
int was_active = ev_is_active(&timer->watcher_);
151151

152-
ev_tstamp repeat = NODE_V8_UNIXTIME(args[0]);
153-
if (repeat > 0) timer->watcher_.repeat = repeat;
152+
if (args.Length() > 0) {
153+
ev_tstamp repeat = NODE_V8_UNIXTIME(args[0]);
154+
if (repeat > 0) timer->watcher_.repeat = repeat;
155+
}
154156

155157
ev_timer_again(EV_DEFAULT_UC_ &timer->watcher_);
156158

src/node_timer.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ class Timer : ObjectWrap {
1515
protected:
1616
static v8::Persistent<v8::FunctionTemplate> constructor_template;
1717

18-
Timer () : ObjectWrap () { }
18+
Timer () : ObjectWrap () {
19+
// dummy timeout values
20+
ev_timer_init(&watcher_, OnTimeout, 0., 1.);
21+
}
1922
~Timer();
2023

2124
static v8::Handle<v8::Value> New (const v8::Arguments& args);

0 commit comments

Comments
 (0)