We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 177de8f commit 836e6a3Copy full SHA for 836e6a3
1 file changed
src/node_timer.cc
@@ -147,9 +147,22 @@ Handle<Value> Timer::Again(const Arguments& args) {
147
HandleScope scope;
148
Timer *timer = ObjectWrap::Unwrap<Timer>(args.Holder());
149
150
+ int was_active = ev_is_active(&timer->watcher_);
151
+
152
ev_tstamp repeat = NODE_V8_UNIXTIME(args[0]);
153
if (repeat > 0) timer->watcher_.repeat = repeat;
154
155
ev_timer_again(EV_DEFAULT_UC_ &timer->watcher_);
156
157
+ // ev_timer_again can start or stop the watcher.
158
+ // So we need to check what happened and adjust the ref count
159
+ // appropriately.
160
161
+ if (ev_is_active(&timer->watcher_)) {
162
+ if (!was_active) timer->Ref();
163
+ } else {
164
+ if (was_active) timer->Unref();
165
+ }
166
167
return Undefined();
168
}
0 commit comments