src: set node_is_initialized in node::Init
authorCheng Zhao <zcbenz@gmail.com>
Mon, 12 Jan 2015 21:31:25 +0000 (13:31 -0800)
committerBen Noordhuis <info@bnoordhuis.nl>
Tue, 20 Jan 2015 23:13:36 +0000 (00:13 +0100)
This can make node_is_initialized correctly set to true for applications
that use node::Init to embed iojs.

PR-URL: https://github.com/iojs/io.js/pull/225/
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
src/node.cc

index 59a5b31901fc4789cb495f05cc0a11a5b5684cf4..c9aaf7fb1c8aa5b2e9756532417b9faf21a34267 100644 (file)
@@ -3426,6 +3426,11 @@ void Init(int* argc,
   if (!use_debug_agent) {
     RegisterDebugSignalHandler();
   }
+
+  // We should set node_is_initialized here instead of in node::Start,
+  // otherwise embedders using node::Init to initialize everything will not be
+  // able to set it and native modules will not load for them.
+  node_is_initialized = true;
 }
 
 
@@ -3634,7 +3639,6 @@ int Start(int argc, char** argv) {
 
   int code;
   V8::Initialize();
-  node_is_initialized = true;
 
   // Fetch a reference to the main isolate, so we have a reference to it
   // even when we need it to access it from another (debugger) thread.