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

Make gethostbyaddr fail with ECANCELLED for ares_cancel() #138

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
2 changes: 1 addition & 1 deletion ares_gethostbyaddr.c
Expand Up @@ -157,7 +157,7 @@ static void addr_callback(void *arg, int status, int timeouts,
}
end_aquery(aquery, status, host);
}
else if (status == ARES_EDESTRUCTION)
else if (status == ARES_EDESTRUCTION || status == ARES_ECANCELLED)
end_aquery(aquery, status, NULL);
else
next_lookup(aquery);
Expand Down
12 changes: 12 additions & 0 deletions test/ares-test-mock.cc
Expand Up @@ -883,6 +883,18 @@ TEST_P(MockChannelTest, CancelImmediate) {
EXPECT_EQ(0, result.timeouts_);
}

TEST_P(MockChannelTest, CancelImmediateGetHostByAddr) {
HostResult result;
struct in_addr addr;
addr.s_addr = htonl(0x08080808);

ares_gethostbyaddr(channel_, &addr, sizeof(addr), AF_INET, HostCallback, &result);
ares_cancel(channel_);
EXPECT_TRUE(result.done_);
EXPECT_EQ(ARES_ECANCELLED, result.status_);
EXPECT_EQ(0, result.timeouts_);
}

// Relies on retries so is UDP-only
TEST_P(MockUDPChannelTest, CancelLater) {
std::vector<byte> nothing;
Expand Down