Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ref isolate loop

  • Loading branch information...
commit de78922b12c06b80489ec8eb05f0e3d4cd3fe8fa 1 parent f9a47de
Igor Zinkovsky authored
View
3  src/node.cc
@@ -2649,6 +2649,9 @@ void StartThread(node::Isolate* isolate,
if (isolate->id_ > 1) {
process_l->Set(String::NewSymbol("_send"),
FunctionTemplate::New(Isolate::Send)->GetFunction());
+
+ process_l->Set(String::NewSymbol("_exit"),
+ FunctionTemplate::New(Isolate::Unref)->GetFunction());
}
// FIXME crashes with "CHECK(heap->isolate() == Isolate::Current()) failed"
View
2  src/node.js
@@ -135,6 +135,8 @@
msg = JSON.parse('' + msg);
process.emit('message', msg);
};
+
+ process.exit = process._exit;
}
startup.globalVariables = function() {
View
15 src/node_isolate.cc
@@ -215,6 +215,16 @@ Handle<Value> Isolate::Send(const Arguments& args) {
}
+Handle<Value> Isolate::Unref(const Arguments& args) {
+ HandleScope scope;
+
+ Isolate* isolate = Isolate::GetCurrent();
+ uv_unref(isolate->loop_);
+
+ return Undefined();
+}
+
+
void Isolate::OnMessage(IsolateMessage* msg, void* arg) {
HandleScope scope;
@@ -270,6 +280,11 @@ Isolate::Isolate() {
assert(v8_isolate_->GetData() == NULL);
v8_isolate_->SetData(this);
+ // Artificially ref the isolate loop so that the child
+ // isolate stays alive by default. process.exit will
+ // unref the loop (see Isolate::Unref).
+ uv_ref(loop_);
+
globals_init_ = false;
}
View
1  src/node_isolate.h
@@ -74,6 +74,7 @@ class Isolate {
typedef void (*AtExitCallback)(void* arg);
static v8::Handle<v8::Value> Send(const v8::Arguments& args);
+ static v8::Handle<v8::Value> Unref(const v8::Arguments& args);
static Isolate* GetCurrent() {
return reinterpret_cast<Isolate*>(v8::Isolate::GetCurrent()->GetData());
View
1  test/simple/test-isolates0.js
@@ -52,6 +52,7 @@ if (process.tid === 1) {
fs.stat(__dirname, function(err, stat) {
if (err) throw err;
console.error('thread 2', stat.mtime);
+ process.exit();
});
}, 500);
Please sign in to comment.
Something went wrong with that request. Please try again.