summaryrefslogtreecommitdiff
path: root/src/handle_wrap.cc
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2011-09-27 15:01:12 -0700
committerRyan Dahl <ry@tinyclouds.org>2011-09-27 15:01:28 -0700
commit7e62bc9828ab0cf322a0769702656f824fe8165c (patch)
tree6f36ca94e5de55d5965b225156a74076ff21e623 /src/handle_wrap.cc
parent0a42266824edc10049f26659c83a35e304866617 (diff)
downloadnode-new-7e62bc9828ab0cf322a0769702656f824fe8165c.tar.gz
Move process.stdout unref hack to handle_wrap.cc
See #1726
Diffstat (limited to 'src/handle_wrap.cc')
-rw-r--r--src/handle_wrap.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc
index c1bdef9d54..b82418ab37 100644
--- a/src/handle_wrap.cc
+++ b/src/handle_wrap.cc
@@ -34,6 +34,23 @@ void HandleWrap::Initialize(Handle<Object> target) {
}
+// This function is used only for process.stdout. It's put here instead of
+// in TTYWrap because here we have access to the Close binding.
+Handle<Value> HandleWrap::Unref(const Arguments& args) {
+ HandleScope scope;
+
+ UNWRAP
+
+ // Calling this function twice should never happen.
+ assert(wrap->unref == false);
+
+ wrap->unref = true;
+ uv_unref(uv_default_loop());
+
+ return v8::Undefined();
+}
+
+
Handle<Value> HandleWrap::Close(const Arguments& args) {
HandleScope scope;
@@ -42,6 +59,11 @@ Handle<Value> HandleWrap::Close(const Arguments& args) {
assert(!wrap->object_.IsEmpty());
uv_close(wrap->handle__, OnClose);
+ if (wrap->unref) {
+ uv_ref(uv_default_loop());
+ wrap->unref = false;
+ }
+
wrap->StateChange();
return v8::Null();
@@ -49,6 +71,7 @@ Handle<Value> HandleWrap::Close(const Arguments& args) {
HandleWrap::HandleWrap(Handle<Object> object, uv_handle_t* h) {
+ unref = false;
handle__ = h;
if (h) {
h->data = this;