Skip to content

Commit

Permalink
src: use global SealHandleScope
Browse files Browse the repository at this point in the history
Helps to find Handle leaks in Debug mode.

PR-URL: #1395
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
indutny committed Apr 11, 2015
1 parent a5244d3 commit a07c691
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ using v8::ObjectTemplate;
using v8::Promise;
using v8::PromiseRejectMessage;
using v8::PropertyCallbackInfo;
using v8::SealHandleScope;
using v8::String;
using v8::TryCatch;
using v8::Uint32;
Expand Down Expand Up @@ -3836,22 +3837,25 @@ static void StartNodeInstance(void* arg) {
if (instance_data->use_debug_agent())
EnableDebug(env);

bool more;
do {
v8::platform::PumpMessageLoop(default_platform, isolate);
more = uv_run(env->event_loop(), UV_RUN_ONCE);

if (more == false) {
{
SealHandleScope seal(isolate);
bool more;
do {
v8::platform::PumpMessageLoop(default_platform, isolate);
EmitBeforeExit(env);
more = uv_run(env->event_loop(), UV_RUN_ONCE);

// 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);
if (more == false) {
v8::platform::PumpMessageLoop(default_platform, isolate);
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);
}

int exit_code = EmitExit(env);
if (instance_data->is_main())
Expand Down

0 comments on commit a07c691

Please sign in to comment.