aboutsummaryrefslogtreecommitdiff
path: root/ares/ares_process.c
diff options
context:
space:
mode:
authorPhil Blundell <pb@reciva.com>2009-01-13 11:51:04 +0000
committerPhil Blundell <pb@reciva.com>2009-01-13 11:51:04 +0000
commit35d8fb05017af9ee8514cb317cb37fc2ce5185a9 (patch)
tree9e5165c13033b6700865b7e5026e92aff50314e9 /ares/ares_process.c
parent87c71953bee0760d106b12ef4f11c09ddfdeffbd (diff)
- ares__send_query() now varies the retry timeout pseudo-randomly to avoid
packet storms when several queries were started at the same time.
Diffstat (limited to 'ares/ares_process.c')
-rw-r--r--ares/ares_process.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/ares/ares_process.c b/ares/ares_process.c
index 8c25b11da..3aa75cdae 100644
--- a/ares/ares_process.c
+++ b/ares/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.
*/