Browse Source

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 13 years ago
committed by Ben Noordhuis
parent
commit
9a6012edd9
  1. 52
      src/node.cc

52
src/node.cc

@ -2644,32 +2644,38 @@ int Start(int argc, char *argv[]) {
// This needs to run *before* V8::Initialize() // This needs to run *before* V8::Initialize()
argv = Init(argc, argv); argv = Init(argc, argv);
v8::V8::Initialize(); V8::Initialize();
v8::HandleScope handle_scope; Persistent<Context> context;
{
// Create the one and only Context. Locker locker;
Persistent<v8::Context> context = v8::Context::New(); HandleScope handle_scope;
v8::Context::Scope context_scope(context);
// Create the one and only Context.
Handle<Object> process_l = SetupProcessObject(argc, argv); Persistent<Context> context = Context::New();
v8_typed_array::AttachBindings(context->Global()); Context::Scope context_scope(context);
// Create all the objects, load modules, do everything. Handle<Object> process_l = SetupProcessObject(argc, argv);
// so your next reading stop should be node::Load()! v8_typed_array::AttachBindings(context->Global());
Load(process_l);
// Create all the objects, load modules, do everything.
// All our arguments are loaded. We've evaluated all of the scripts. We // so your next reading stop should be node::Load()!
// might even have created TCP servers. Now we enter the main eventloop. If Load(process_l);
// there are no watchers on the loop (except for the ones that were
// uv_unref'd) then this function exits. As long as there are active // All our arguments are loaded. We've evaluated all of the scripts. We
// watchers, it blocks. // might even have created TCP servers. Now we enter the main eventloop. If
uv_run(uv_default_loop()); // there are no watchers on the loop (except for the ones that were
// uv_unref'd) then this function exits. As long as there are active
EmitExit(process_l); // watchers, it blocks.
uv_run(uv_default_loop());
EmitExit(process_l);
#ifndef NDEBUG
context.Dispose();
#endif
}
#ifndef NDEBUG #ifndef NDEBUG
// Clean up. // Clean up.
context.Dispose();
V8::Dispose(); V8::Dispose();
#endif // NDEBUG #endif // NDEBUG

Loading…
Cancel
Save