summaryrefslogtreecommitdiff
path: root/ares_send.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2008-11-01 18:35:19 +0000
committerDaniel Stenberg <daniel@haxx.se>2008-11-01 18:35:19 +0000
commit1a1b4eb4f2fb6112534994c20ac20679c5c7339c (patch)
tree76fda13f7f58853b63f184e061cb75eec6922d44 /ares_send.c
parentaa8d8b4933ca1f5de8da3f92f614e5f3236d6f89 (diff)
downloadc-ares-1a1b4eb4f2fb6112534994c20ac20679c5c7339c.tar.gz
c-ares-1a1b4eb4f2fb6112534994c20ac20679c5c7339c.tar.bz2
c-ares-1a1b4eb4f2fb6112534994c20ac20679c5c7339c.zip
- Carlo Contavalli added support for the glibc "rotate" option, as documented
in man resolv.conf: causes round robin selection of nameservers from among those listed. This has the effect of spreading the query load among all listed servers, rather than having all clients try the first listed server first every time. You can enable it with ARES_OPT_ROTATE
Diffstat (limited to 'ares_send.c')
-rw-r--r--ares_send.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ares_send.c b/ares_send.c
index a5811d3..be5478d 100644
--- a/ares_send.c
+++ b/ares_send.c
@@ -95,7 +95,13 @@ void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen,
/* Initialize query status. */
query->try = 0;
- query->server = 0;
+
+ /* Choose the server to send the query to. If rotation is enabled, keep track
+ * of the next server we want to use. */
+ query->server = channel->last_server;
+ if (channel->rotate == 1)
+ channel->last_server = (channel->last_server + 1) % channel->nservers;
+
for (i = 0; i < channel->nservers; i++)
{
query->server_info[i].skip_server = 0;