diff options
author | Peter Rybin <peter.rybin@gmail.com> | 2012-07-03 23:21:37 +0400 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2012-07-23 13:15:51 +0200 |
commit | 688859afc09307d358b3f160cdd9aff2d2ce6c6f (patch) | |
tree | 2ddf0a148f376195f4c648ea1af29ed1c455b82a /src | |
parent | e06b5d7af7619e9234bb7eb8a9d66b3c7d245ad9 (diff) | |
download | node-688859afc09307d358b3f160cdd9aff2d2ce6c6f.tar.gz |
debugger: wake up the event loop when a debugger command is dispatched
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
Diffstat (limited to 'src')
-rw-r--r-- | src/node.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/node.cc b/src/node.cc index 05208b44b..257b96e9e 100644 --- a/src/node.cc +++ b/src/node.cc @@ -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, |