Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
debugger: wake up the event loop when a debugger command is dispatched
Browse files Browse the repository at this point in the history
When the event loop was blocked in epoll / kqueue or similar, debugger
commands wouldn't be processed. This patch fixes that by adding an
uv_async handle which is triggered when a debugger command is
dispatched. The async handle's callback makes sure that V8 is entered.

Closes GH-3626
Closes GH-3718
  • Loading branch information
prybin authored and piscisaureus committed Jul 23, 2012
1 parent e06b5d7 commit 688859a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/node.cc
Expand Up @@ -2471,11 +2471,35 @@ static void ParseArgs(int argc, char **argv) {
static Isolate* node_isolate = NULL;
static volatile bool debugger_running = false;


static uv_async_t dispatch_debug_messages_async;


// Called from the main thread.
static void DispatchDebugMessagesAsyncCallback(uv_async_t* handle, int status) {
v8::Debug::ProcessDebugMessages();
}


// Called from V8 Debug Agent TCP thread.
static void DispatchMessagesDebugAgentCallback() {
uv_async_send(&dispatch_debug_messages_async);
}


static void EnableDebug(bool wait_connect) {
// If we're called from another thread, make sure to enter the right
// v8 isolate.
node_isolate->Enter();

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,
Expand Down

0 comments on commit 688859a

Please sign in to comment.