- ares__send_query() now varies the retry timeout pseudo-randomly to avoid

packet storms when several queries were started at the same time.
pull/1/head
Phil Blundell 16 years ago
parent 8362245c42
commit 977de8c778
  1. 6
      CHANGES
  2. 5
      ares_process.c

@ -1,6 +1,10 @@
Changelog for the c-ares project Changelog for the c-ares project
* January 11 2008 (Daniel Stenberg) * January 13 2009 (Phil Blundell)
- ares__send_query() now varies the retry timeout pseudo-randomly to avoid
packet storms when several queries were started at the same time.
* January 11 2009 (Daniel Stenberg)
- Phil Blundell added the internal function ares__expand_name_for_response() - Phil Blundell added the internal function ares__expand_name_for_response()
that is now used by the ares_parse_*_reply() functions instead of the that is now used by the ares_parse_*_reply() functions instead of the
ares_expand_name() simply to easier return ARES_EBADRESP for the cases where ares_expand_name() simply to easier return ARES_EBADRESP for the cases where

@ -715,6 +715,7 @@ void ares__send_query(ares_channel channel, struct query *query,
{ {
struct send_request *sendreq; struct send_request *sendreq;
struct server_state *server; struct server_state *server;
int timeplus;
server = &channel->servers[query->server]; server = &channel->servers[query->server];
if (query->using_tcp) if (query->using_tcp)
@ -778,9 +779,11 @@ void ares__send_query(ares_channel channel, struct query *query,
return; return;
} }
} }
timeplus = channel->timeout << (query->try / channel->nservers);
timeplus = (timeplus * (9 + (rand () & 7))) / 16;
query->timeout = *now; query->timeout = *now;
ares__timeadd(&query->timeout, ares__timeadd(&query->timeout,
channel->timeout << (query->try / channel->nservers)); timeplus);
/* Keep track of queries bucketed by timeout, so we can process /* Keep track of queries bucketed by timeout, so we can process
* timeout events quickly. * timeout events quickly.
*/ */

Loading…
Cancel
Save