Skip to content

Commit

Permalink
src: fix dns crash when failed to create NodeAresTask
Browse files Browse the repository at this point in the history
PR-URL: #55521
Fixes: #52439
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
theanarkh authored and RafaelGSS committed Nov 1, 2024
1 parent 2b99285 commit 4c34891
Showing 1 changed file with 4 additions and 9 deletions.
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

0 comments on commit 4c34891

Please sign in to comment.