diff --git a/src/lib/ares_process.c b/src/lib/ares_process.c index ca6d9db1..d65293b9 100644 --- a/src/lib/ares_process.c +++ b/src/lib/ares_process.c @@ -562,6 +562,7 @@ static void process_timeouts(ares_channel_t *channel, struct timeval *now) query->timeouts++; conn = query->conn; + server_increment_failures(conn->server); ares__requeue_query(query, now); ares__check_cleanup_conn(channel, conn); diff --git a/test/ares-test-mock.cc b/test/ares-test-mock.cc index 6c490d32..0864ecc8 100644 --- a/test/ares-test-mock.cc +++ b/test/ares-test-mock.cc @@ -1341,6 +1341,30 @@ TEST_P(NoRotateMultiMockTest, ThirdServer) { CheckExample(); } +TEST_P(NoRotateMultiMockTest, ServerNoResponseFailover) { + std::vector nothing; + DNSPacket okrsp; + okrsp.set_response().set_aa() + .add_question(new DNSQuestion("www.example.com", T_A)) + .add_answer(new DNSARR("www.example.com", 100, {2,3,4,5})); + + ON_CALL(*servers_[0], OnRequest("www.example.com", T_A)) + .WillByDefault(SetReplyData(servers_[0].get(), nothing)); + ON_CALL(*servers_[1], OnRequest("www.example.com", T_A)) + .WillByDefault(SetReplyData(servers_[1].get(), nothing)); + EXPECT_CALL(*servers_[2], OnRequest("www.example.com", T_A)) + .WillOnce(SetReply(servers_[2].get(), &okrsp)); + + HostResult result; + ares_gethostbyname(channel_, "www.example.com.", AF_INET, HostCallback, &result); + Process(); + EXPECT_TRUE(result.done_); + EXPECT_EQ(2, result.timeouts_); + std::stringstream ss; + ss << result.host_; + EXPECT_EQ("{'www.example.com' aliases=[] addrs=[2.3.4.5]}", ss.str()); +} + INSTANTIATE_TEST_SUITE_P(AddressFamilies, MockChannelTest, ::testing::ValuesIn(ares::test::families_modes)); INSTANTIATE_TEST_SUITE_P(AddressFamilies, MockUDPChannelTest, ::testing::ValuesIn(ares::test::families));