Browse Source

node: `EmitExit` should not call `exit()`

Before this commit `RunAtExit` and `env->Dispose()` were never reached,
because `EmitExit` was always colling `exit`.
v0.11.11-release
Fedor Indutny 11 years ago
parent
commit
e57ab7ba06
  1. 2
      src/env-inl.h
  2. 9
      src/node.cc

2
src/env-inl.h

@ -190,6 +190,8 @@ inline Environment::Environment(v8::Local<v8::Context> context)
}
inline Environment::~Environment() {
v8::HandleScope handle_scope(isolate());
context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex, NULL);
#define V(PropertyName, TypeName) PropertyName ## _.Dispose();
ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V)

9
src/node.cc

@ -3315,7 +3315,7 @@ void AtExit(void (*cb)(void* arg), void* arg) {
}
void EmitExit(Environment* env) {
int EmitExit(Environment* env) {
// process.emit('exit')
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());
@ -3332,7 +3332,7 @@ void EmitExit(Environment* env) {
};
MakeCallback(env, process_object, "emit", ARRAY_SIZE(args), args);
exit(code);
return code;
}
@ -3406,6 +3406,7 @@ int Start(int argc, char** argv) {
V8::SetEntropySource(crypto::EntropySource);
#endif
int code;
V8::Initialize();
{
Locker locker(node_isolate);
@ -3417,7 +3418,7 @@ int Start(int argc, char** argv) {
// be removed.
Context::Scope context_scope(env->context());
uv_run(env->event_loop(), UV_RUN_DEFAULT);
EmitExit(env);
code = EmitExit(env);
RunAtExit(env);
env->Dispose();
env = NULL;
@ -3431,7 +3432,7 @@ int Start(int argc, char** argv) {
delete[] exec_argv;
exec_argv = NULL;
return 0;
return code;
}

Loading…
Cancel
Save