diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-11-11 21:03:08 +0100 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-11-12 22:01:21 +0100 |
commit | fd819efbdfbcf03d4f68b297f9003e160bb6b58d (patch) | |
tree | 6de2f4f6aa630fc692972acdb1d818f80574a80c | |
parent | 09724b311ee44e6c7998c7a5cb39e739609eba66 (diff) | |
download | node-new-fd819efbdfbcf03d4f68b297f9003e160bb6b58d.tar.gz |
src: remove global HandleScope
Make it more difficult to accidentally leak handles by removing the
top-level HandleScope. Now if there's no valid HandleScope now, V8
will complain and, in debug builds, abort.
-rw-r--r-- | src/node.cc | 5 | ||||
-rw-r--r-- | src/tls_wrap.cc | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/node.cc b/src/node.cc index 93926cd8bd..3153392efd 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3249,8 +3249,11 @@ int Start(int argc, char** argv) { Locker locker(node_isolate); Environment* env = CreateEnvironment(node_isolate, argc, argv, exec_argc, exec_argv); + // This Context::Scope is here so EnableDebug() can look up the current + // environment with Environment::GetCurrentChecked(). + // TODO(bnoordhuis) Reorder the debugger initialization logic so it can + // be removed. Context::Scope context_scope(env->context()); - HandleScope handle_scope(env->isolate()); uv_run(env->event_loop(), UV_RUN_DEFAULT); EmitExit(env); RunAtExit(env); diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 2dd8016c59..5c837fa22e 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -235,9 +235,8 @@ void TLSCallbacks::SSLInfoCallback(const SSL* ssl_, int where, int ret) { SSL* ssl = const_cast<SSL*>(ssl_); TLSCallbacks* c = static_cast<TLSCallbacks*>(SSL_get_app_data(ssl)); Environment* env = c->env(); - // There should be a Context::Scope a few stack frames down. - assert(env->context() == env->isolate()->GetCurrentContext()); HandleScope handle_scope(env->isolate()); + Context::Scope context_scope(env->context()); Local<Object> object = c->object(); if (where & SSL_CB_HANDSHAKE_START) { |