Re-add top-level v8::Locker

11d1eca9 added a v8 locker to ease development of 3rd party threading
extensions but it created a condition which would cause node to exit
uncleanly while in debug mode; it was reverted in 7543c38d.

The problem here is that the Locker was being disposed after V8 was torn
down. Adding some scoping fixes that.
v0.7.4-release
Marcel Laverdet 2012-02-07 18:10:22 -06:00 committed by Ben Noordhuis
parent e612143a89
commit 9a6012edd9
1 changed files with 24 additions and 18 deletions

View File

@ -2644,12 +2644,15 @@ int Start(int argc, char *argv[]) {
// This needs to run *before* V8::Initialize()
argv = Init(argc, argv);
v8::V8::Initialize();
v8::HandleScope handle_scope;
V8::Initialize();
Persistent<Context> context;
{
Locker locker;
HandleScope handle_scope;
// Create the one and only Context.
Persistent<v8::Context> context = v8::Context::New();
v8::Context::Scope context_scope(context);
Persistent<Context> context = Context::New();
Context::Scope context_scope(context);
Handle<Object> process_l = SetupProcessObject(argc, argv);
v8_typed_array::AttachBindings(context->Global());
@ -2666,10 +2669,13 @@ int Start(int argc, char *argv[]) {
uv_run(uv_default_loop());
EmitExit(process_l);
#ifndef NDEBUG
context.Dispose();
#endif
}
#ifndef NDEBUG
// Clean up.
context.Dispose();
V8::Dispose();
#endif // NDEBUG