Created
April 15, 2010 19:19
-
-
Save ry/367521 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ba3c0162d3d84ed293b7b667f99a034839ea7382 Mon Sep 17 00:00:00 2001 | |
From: Ryan Dahl <ry@tinyclouds.org> | |
Date: Thu, 15 Apr 2010 12:19:24 -0700 | |
Subject: [PATCH] unref gc_idle watcher | |
--- | |
lib/http.js | 2 +- | |
src/node.cc | 20 +++++++++++++++++--- | |
2 files changed, 18 insertions(+), 4 deletions(-) | |
diff --git a/lib/http.js b/lib/http.js | |
index 1bb2e96..00e9ae3 100644 | |
--- a/lib/http.js | |
+++ b/lib/http.js | |
@@ -496,7 +496,6 @@ function flushMessageQueue (socket, queue) { | |
return false; | |
} | |
- | |
function Server (requestListener) { | |
net.Server.call(this); | |
this.addListener("request", requestListener); | |
@@ -510,6 +509,7 @@ exports.createServer = function (requestListener) { | |
return new Server(requestListener); | |
}; | |
+ | |
function connectionListener (socket) { | |
var self = this; | |
// An array of responses for each socket. In pipelined connections | |
diff --git a/src/node.cc b/src/node.cc | |
index cabd92a..452a4ac 100644 | |
--- a/src/node.cc | |
+++ b/src/node.cc | |
@@ -118,6 +118,20 @@ static void gc_timer_stop () { | |
} | |
} | |
+static void gc_idle_start () { | |
+ if (!ev_is_active(&gc_idle)) { | |
+ ev_idle_start(EV_DEFAULT_UC_ &gc_idle); | |
+ ev_unref(EV_DEFAULT_UC); | |
+ } | |
+} | |
+ | |
+static void gc_idle_stop () { | |
+ if (ev_is_active(&gc_idle)) { | |
+ ev_ref(EV_DEFAULT_UC); | |
+ ev_idle_stop(EV_DEFAULT_UC_ &gc_idle); | |
+ } | |
+} | |
+ | |
static void CheckIdleness(EV_P_ ev_timer *watcher, int revents) { | |
assert(watcher == &gc_timer); | |
@@ -129,7 +143,7 @@ static void CheckIdleness(EV_P_ ev_timer *watcher, int revents) { | |
if (idle_time > GC_INTERVAL) { | |
if (!V8::IdleNotification()) { | |
- ev_idle_start(EV_DEFAULT_UC_ &gc_idle); | |
+ gc_idle_start(); | |
} | |
gc_timer_stop(); | |
} | |
@@ -143,7 +157,7 @@ static void NotifyIdleness(EV_P_ ev_idle *watcher, int revents) { | |
//fprintf(stderr, "notify idle\n"); | |
if (V8::IdleNotification()) { | |
- ev_idle_stop(EV_A_ watcher); | |
+ gc_idle_stop(); | |
gc_timer_stop(); | |
} | |
} | |
@@ -167,7 +181,7 @@ static void Activity(EV_P_ ev_check *watcher, int revents) { | |
if (pending) { | |
last_active = ev_now(EV_DEFAULT_UC); | |
- ev_idle_stop(EV_DEFAULT_UC_ &gc_idle); | |
+ gc_idle_stop(); | |
gc_timer_start(); | |
} | |
} | |
-- | |
1.6.6 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment