inspector: fix abort when two Environments own the inspector by codebytere · Pull Request #65877 · nodejs/node · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 71 additions & 58 deletions src/inspector_agent.cc
10 changes: 9 additions & 1 deletion src/inspector_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#endif

#include "node_options.h"
#include "uv.h"
#include "v8.h"

#include <cstddef>
Expand Down Expand Up @@ -117,7 +118,8 @@ class Agent {
// Can only be called from the main thread.
bool StartIoThread();

// Calls StartIoThread() from off the main thread.
// Calls StartIoThread() from off the main thread. Only valid while the
// Environment owns the inspector and has not started cleanup.
void RequestIoThreadStart();

const DebugOptions& options() { return debug_options_; }
Expand Down Expand Up @@ -156,6 +158,12 @@ class Agent {
bool async_hook_enabled_ = false;
bool syncing_async_hook_state_ = false;

// Woken by the SIGUSR1 watchdog; closed by the cleanup hook or ~Agent(),
// whichever runs first, and freed by its close callback.
uv_async_t* start_io_thread_async_ = nullptr;
void StopAcceptingIoThreadStarts();
static void StopAcceptingIoThreadStartsHook(void* agent);

bool network_tracking_enabled_ = false;
bool pending_enable_network_tracking = false;
bool pending_disable_network_tracking = false;
Expand Down
6 changes: 4 additions & 2 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ enum Flags : uint32_t {
kNoICU = 1 << 3,
// Do not modify stdio file descriptor or TTY state.
kNoStdioInitialization = 1 << 4,
// Do not register Node.js-specific signal handlers
// and reset other signal handlers to default state.
// Do not register Node.js-specific signal handlers, reset other signal
// handlers to default state, or replace the calling thread's signal mask
// (without this flag, POSIX builds with the inspector set it to block
// SIGUSR1 and nothing else).
kNoDefaultSignalHandling = 1 << 5,
// Do not perform V8 initialization.
kNoInitializeV8 = 1 << 6,
Expand Down
3 changes: 1 addition & 2 deletions test/cctest/test_environment.cc
Loading