From 409f6a9d3039d5ff64caf497b39f741b05e029e9 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Wed, 23 Sep 2015 16:36:10 -0600 Subject: [PATCH] src: use global SealHandleScope Helps to find Handle leaks in Debug mode. Ref: a5244d3 "deps: backport 1f8555 from v8's upstream" PR-URL: https://github.com/nodejs/node/pull/3945 Reviewed-By: Fedor Indutny Reviewed-By: James Snell --- src/node.cc | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/node.cc b/src/node.cc index 1da83287c1b42d..200f67bdcbdf73 100644 --- a/src/node.cc +++ b/src/node.cc @@ -115,6 +115,7 @@ using v8::Number; using v8::Object; using v8::ObjectTemplate; using v8::PropertyCallbackInfo; +using v8::SealHandleScope; using v8::String; using v8::TryCatch; using v8::Uint32; @@ -3755,19 +3756,23 @@ int Start(int argc, char** argv) { if (use_debug_agent) EnableDebug(env); - bool more; - do { - more = uv_run(env->event_loop(), UV_RUN_ONCE); - if (more == false) { - EmitBeforeExit(env); - - // Emit `beforeExit` if the loop became alive either after emitting - // event, or after running some callbacks. - more = uv_loop_alive(env->event_loop()); - if (uv_run(env->event_loop(), UV_RUN_NOWAIT) != 0) - more = true; - } - } while (more == true); + { + SealHandleScope seal(node_isolate); + bool more; + do { + more = uv_run(env->event_loop(), UV_RUN_ONCE); + if (more == false) { + EmitBeforeExit(env); + + // Emit `beforeExit` if the loop became alive either after emitting + // event, or after running some callbacks. + more = uv_loop_alive(env->event_loop()); + if (uv_run(env->event_loop(), UV_RUN_NOWAIT) != 0) + more = true; + } + } while (more == true); + } + code = EmitExit(env); RunAtExit(env);