Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Only Ref in idle watcher when wasn't already active.

  • Loading branch information...
commit 49d30c6478df14ca41540ee7c8d8d9279f2a3651 1 parent 7be0d06
Herbert Vojčík herby authored ry committed
Showing with 9 additions and 5 deletions.
  1. +8 −5 src/node_idle_watcher.cc
  2. +1 −0  src/node_idle_watcher.h
13 src/node_idle_watcher.cc
View
@@ -88,14 +88,17 @@ Handle<Value> IdleWatcher::New(const Arguments& args) {
Handle<Value> IdleWatcher::Start(const Arguments& args) {
HandleScope scope;
-
IdleWatcher *idle = ObjectWrap::Unwrap<IdleWatcher>(args.Holder());
+ idle->Start();
+ return Undefined();
+}
- ev_idle_start(EV_DEFAULT_UC_ &idle->watcher_);
-
- idle->Ref();
- return Undefined();
+void IdleWatcher::Start () {
+ if (!watcher_.active) {
+ ev_idle_start(EV_DEFAULT_UC_ &watcher_);
+ Ref();
+ }
}
1  src/node_idle_watcher.h
View
@@ -31,6 +31,7 @@ class IdleWatcher : ObjectWrap {
private:
static void Callback(EV_P_ ev_idle *watcher, int revents);
+ void Start();
void Stop();
ev_idle watcher_;
Please sign in to comment.
Something went wrong with that request. Please try again.