Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspector: properly shut down uv_async_t #30612

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/inspector_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -749,12 +749,6 @@ Agent::Agent(Environment* env)
host_port_(env->inspector_host_port()) {}

Agent::~Agent() {
if (start_io_thread_async.data == this) {
CHECK(start_io_thread_async_initialized.exchange(false));
start_io_thread_async.data = nullptr;
// This is global, will never get freed
uv_close(reinterpret_cast<uv_handle_t*>(&start_io_thread_async), nullptr);
}
}
addaleax marked this conversation as resolved.
Show resolved Hide resolved

bool Agent::Start(const std::string& path,
Expand All @@ -776,6 +770,16 @@ bool Agent::Start(const std::string& path,
start_io_thread_async.data = this;
// Ignore failure, SIGUSR1 won't work, but that should not block node start.
StartDebugSignalHandler();

parent_env_->AddCleanupHook([](void* data) {
Environment* env = static_cast<Environment*>(data);

// This is global, will never get freed
env->CloseHandle(&start_io_thread_async, [](uv_async_t*) {
start_io_thread_async.data = nullptr;
CHECK(start_io_thread_async_initialized.exchange(false));
});
}, parent_env_);
bnoordhuis marked this conversation as resolved.
Show resolved Hide resolved
}

AtExit(parent_env_, [](void* env) {
Expand Down