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

src: do not unnecessarily re-assign uv handle data #31696

Closed
wants to merge 1 commit into from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/handle_wrap.cc
Expand Up @@ -115,6 +115,7 @@ HandleWrap::HandleWrap(Environment* env,


void HandleWrap::OnClose(uv_handle_t* handle) {
CHECK_NOT_NULL(handle->data);
BaseObjectPtr<HandleWrap> wrap { static_cast<HandleWrap*>(handle->data) };
wrap->Detach();

Expand Down
9 changes: 4 additions & 5 deletions src/node_messaging.cc
Expand Up @@ -488,10 +488,9 @@ MessagePort::MessagePort(Environment* env,
CHECK_EQ(uv_async_init(env->event_loop(),
&async_,
onmessage), 0);
async_.data = nullptr; // Reset later to indicate success of the constructor.
auto cleanup = OnScopeLeave([&]() {
if (async_.data == nullptr) Close();
});
// Reset later to indicate success of the constructor.
bool succeeded = false;
auto cleanup = OnScopeLeave([&]() { if (!succeeded) Close(); });

Local<Value> fn;
if (!wrap->Get(context, env->oninit_symbol()).ToLocal(&fn))
Expand All @@ -508,7 +507,7 @@ MessagePort::MessagePort(Environment* env,
return;
emit_message_fn_.Reset(env->isolate(), emit_message_fn);

async_.data = static_cast<void*>(this);
succeeded = true;
Debug(this, "Created message port");
}

Expand Down