mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
core: Use a uv_signal for debug listener
Starting the debugger directly in the SIGUSR1 signal handler results in a malloc lock contention ~1% of the time. It hangs the test, which is annoying on a daily basis to all of us, but it also is pretty terrible if you actually want to debug a node process that has gone sideways. Credit to @bnoordhuis for most of this. I just added the unref which keeps it from messing up the event loop for other stuff.
This commit is contained in:
1 parent
7bc449c063
commit
30e5366b29
1 file changed
+5
-2
+5
-2
@@ -2715,7 +2715,7 @@ static void EnableDebug(bool wait_connect) {
|
|||||||
|
|
||||||
|
|
||||||
#ifdef __POSIX__
|
#ifdef __POSIX__
|
||||||
static void EnableDebugSignalHandler(int signal) {
|
static void EnableDebugSignalHandler(uv_signal_t* handle, int) {
|
||||||
// Break once process will return execution to v8
|
// Break once process will return execution to v8
|
||||||
v8::Debug::DebugBreak(node_isolate);
|
v8::Debug::DebugBreak(node_isolate);
|
||||||
|
|
||||||
@@ -2997,7 +2997,10 @@ char** Init(int argc, char *argv[]) {
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
RegisterDebugSignalHandler();
|
RegisterDebugSignalHandler();
|
||||||
#else // Posix
|
#else // Posix
|
||||||
RegisterSignalHandler(SIGUSR1, EnableDebugSignalHandler);
|
static uv_signal_t signal_watcher;
|
||||||
|
uv_signal_init(uv_default_loop(), &signal_watcher);
|
||||||
|
uv_signal_start(&signal_watcher, EnableDebugSignalHandler, SIGUSR1);
|
||||||
|
uv_unref((uv_handle_t*)&signal_watcher);
|
||||||
#endif // __POSIX__
|
#endif // __POSIX__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user