diff options
author | Phil Blundell <pb@reciva.com> | 2009-01-13 11:51:04 +0000 |
---|---|---|
committer | Phil Blundell <pb@reciva.com> | 2009-01-13 11:51:04 +0000 |
commit | 977de8c7780eeb43efeabbbfa6bac82161ceeaaa (patch) | |
tree | 7a9ab8e77beb4a990c1e05408c23fd71b200bc52 | |
parent | 8362245c42883bf5775d87d2d996b89b6f2f2fed (diff) | |
download | c-ares-977de8c7780eeb43efeabbbfa6bac82161ceeaaa.tar.gz c-ares-977de8c7780eeb43efeabbbfa6bac82161ceeaaa.tar.bz2 c-ares-977de8c7780eeb43efeabbbfa6bac82161ceeaaa.zip |
- ares__send_query() now varies the retry timeout pseudo-randomly to avoid
packet storms when several queries were started at the same time.
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | ares_process.c | 5 |
2 files changed, 9 insertions, 2 deletions
@@ -1,6 +1,10 @@ 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() 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 diff --git a/ares_process.c b/ares_process.c index 8c25b11..3aa75cd 100644 --- a/ares_process.c +++ b/ares_process.c @@ -715,6 +715,7 @@ void ares__send_query(ares_channel channel, struct query *query, { struct send_request *sendreq; struct server_state *server; + int timeplus; server = &channel->servers[query->server]; if (query->using_tcp) @@ -778,9 +779,11 @@ void ares__send_query(ares_channel channel, struct query *query, return; } } + timeplus = channel->timeout << (query->try / channel->nservers); + timeplus = (timeplus * (9 + (rand () & 7))) / 16; query->timeout = *now; ares__timeadd(&query->timeout, - channel->timeout << (query->try / channel->nservers)); + timeplus); /* Keep track of queries bucketed by timeout, so we can process * timeout events quickly. */ |