Browse Source

src: initialize debug-related uv_async_t handles

uv_async_t handles for dispatching of debug messages and
emitting NODE_DEBUG_ENABLED used to be initialized every time
node::EnableDebug() was called, which happened every time
user sends a SIGUSR1.

Now they are initialized only once from node::Init() during
application start.
v0.11.2-release
Miroslav Bajtoš 12 years ago
committed by Ben Noordhuis
parent
commit
fbf4641462
  1. 25
      src/node.cc

25
src/node.cc

@ -2746,12 +2746,8 @@ static void EmitDebugEnabledAsyncCallback(uv_async_t* handle, int status) {
}
// Called from the signal handler (unix) or off-thread (windows)
// Called from the signal watcher callback
static void EmitDebugEnabled() {
uv_async_init(uv_default_loop(),
&emit_debug_enabled_async,
EmitDebugEnabledAsyncCallback);
uv_unref((uv_handle_t*) &emit_debug_enabled_async);
uv_async_send(&emit_debug_enabled_async);
}
@ -2764,11 +2760,6 @@ static void EnableDebug(bool wait_connect) {
v8::Debug::SetDebugMessageDispatchHandler(DispatchMessagesDebugAgentCallback,
false);
uv_async_init(uv_default_loop(),
&dispatch_debug_messages_async,
DispatchDebugMessagesAsyncCallback);
uv_unref((uv_handle_t*) &dispatch_debug_messages_async);
// Start the debug thread and it's associated TCP server on port 5858.
bool r = v8::Debug::EnableAgent("node " NODE_VERSION,
debug_port,
@ -2783,7 +2774,7 @@ static void EnableDebug(bool wait_connect) {
debugger_running = true;
// Do not emit _debug_enabled when debugger is enabled before starting
// Do not emit NODE_DEBUG_ENABLED when debugger is enabled before starting
// the main process (i.e. when called via `node --debug`)
if (!process.IsEmpty())
EmitDebugEnabled();
@ -3016,6 +3007,18 @@ char** Init(int argc, char *argv[]) {
// Make inherited handles noninheritable.
uv_disable_stdio_inheritance();
// init async debug messages dispatching
uv_async_init(uv_default_loop(),
&dispatch_debug_messages_async,
DispatchDebugMessagesAsyncCallback);
uv_unref(reinterpret_cast<uv_handle_t*>(&dispatch_debug_messages_async));
// init async NODE_DEBUG_ENABLED emitter
uv_async_init(uv_default_loop(),
&emit_debug_enabled_async,
EmitDebugEnabledAsyncCallback);
uv_unref(reinterpret_cast<uv_handle_t*>(&emit_debug_enabled_async));
// Parse a few arguments which are specific to Node.
node::ParseArgs(argc, argv);
// Parse the rest of the args (up to the 'option_end_index' (where '--' was

Loading…
Cancel
Save