mirror of https://github.com/nodejs/node.git
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-3718pull/24503/head
parent
e06b5d7af7
commit
688859afc0
24
src/node.cc
24
src/node.cc
|
@ -2471,11 +2471,35 @@ static void ParseArgs(int argc, char **argv) {
|
||||||
static Isolate* node_isolate = NULL;
|
static Isolate* node_isolate = NULL;
|
||||||
static volatile bool debugger_running = false;
|
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) {
|
static void EnableDebug(bool wait_connect) {
|
||||||
// If we're called from another thread, make sure to enter the right
|
// If we're called from another thread, make sure to enter the right
|
||||||
// v8 isolate.
|
// v8 isolate.
|
||||||
node_isolate->Enter();
|
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.
|
// Start the debug thread and it's associated TCP server on port 5858.
|
||||||
bool r = v8::Debug::EnableAgent("node " NODE_VERSION,
|
bool r = v8::Debug::EnableAgent("node " NODE_VERSION,
|
||||||
debug_port,
|
debug_port,
|
||||||
|
|
Loading…
Reference in New Issue