Skip to content
Merged
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
src: fix dns crash when failed to create NodeAresTask
  • Loading branch information
theanarkh committed Oct 24, 2024
commit 81a979a758f85900e88f087d9ff2d4ce63e480b0
13 changes: 4 additions & 9 deletions src/cares_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,10 @@ void ares_sockstate_cb(void* data, ares_socket_t sock, int read, int write) {
ares_poll_cb);

} else {
/* read == 0 and write == 0 this is c-ares's way of notifying us that */
/* the socket is now closed. We must free the data associated with */
/* socket. */
CHECK(task &&
"When an ares socket is closed we should have a handle for it");

channel->task_list()->erase(it);
channel->env()->CloseHandle(&task->poll_watcher, ares_poll_close_cb);
if (task != nullptr) {
channel->task_list()->erase(it);
channel->env()->CloseHandle(&task->poll_watcher, ares_poll_close_cb);
}

if (channel->task_list()->empty()) {
channel->CloseTimer();
Expand Down Expand Up @@ -683,7 +679,6 @@ GetNameInfoReqWrap::GetNameInfoReqWrap(
void ChannelWrap::AresTimeout(uv_timer_t* handle) {
ChannelWrap* channel = static_cast<ChannelWrap*>(handle->data);
CHECK_EQ(channel->timer_handle(), handle);
CHECK_EQ(false, channel->task_list()->empty());
ares_process_fd(channel->cares_channel(), ARES_SOCKET_BAD, ARES_SOCKET_BAD);
}

Expand Down