summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2013-03-31 19:42:11 +0000
committerEric Faurot <eric@cvs.openbsd.org>2013-03-31 19:42:11 +0000
commitf5f677c707792ba5637716fdde07b9e551107163 (patch)
tree4ca33898aedcb937e9a72ad1a7f36d9130138b86 /lib
parent3f605e0f6e1e80006257fa7d5a7b7110fe430a94 (diff)
Principle of least astonishment: implement nameserver retry/backoff as
in the former resolver.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/asr/asr.c12
-rw-r--r--lib/libc/asr/res_send_async.c6
2 files changed, 10 insertions, 8 deletions
diff --git a/lib/libc/asr/asr.c b/lib/libc/asr/asr.c
index ecf31322248..5e4e0e15d06 100644
--- a/lib/libc/asr/asr.c
+++ b/lib/libc/asr/asr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr.c,v 1.17 2013/03/30 20:00:08 eric Exp $ */
+/* $OpenBSD: asr.c,v 1.18 2013/03/31 19:42:10 eric Exp $ */
/*
* Copyright (c) 2010-2012 Eric Faurot <eric@openbsd.org>
*
@@ -531,8 +531,8 @@ asr_ctx_create(void)
ac->ac_hostfile = DEFAULT_HOSTFILE;
ac->ac_nscount = 0;
- ac->ac_nstimeout = 1000;
- ac->ac_nsretries = 3;
+ ac->ac_nstimeout = 5;
+ ac->ac_nsretries = 4;
return (ac);
}
@@ -939,6 +939,12 @@ asr_iter_ns(struct async *as)
DPRINT("asr: asr_iter_ns(): cycle %i\n", as->as_ns_cycles);
}
+ as->as_timeout = 1000 * (as->as_ctx->ac_nstimeout << as->as_ns_cycles);
+ if (as->as_ns_cycles > 0)
+ as->as_timeout /= as->as_ctx->ac_nscount;
+ if (as->as_timeout < 1000)
+ as->as_timeout = 1000;
+
return (0);
}
diff --git a/lib/libc/asr/res_send_async.c b/lib/libc/asr/res_send_async.c
index 374cc4336c5..b7a37b8f3b4 100644
--- a/lib/libc/asr/res_send_async.c
+++ b/lib/libc/asr/res_send_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_send_async.c,v 1.7 2013/03/27 07:40:41 eric Exp $ */
+/* $OpenBSD: res_send_async.c,v 1.8 2013/03/31 19:42:10 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -449,8 +449,6 @@ udp_send(struct async *as)
if (as->as_fd == -1)
return (-1); /* errno set */
- as->as_timeout = as->as_ctx->ac_nstimeout;
-
n = send(as->as_fd, as->as.dns.obuf, as->as.dns.obuflen, 0);
if (n == -1) {
save_errno = errno;
@@ -528,7 +526,6 @@ tcp_write(struct async *as)
as->as_fd = sockaddr_connect(AS_NS_SA(as), SOCK_STREAM);
if (as->as_fd == -1)
return (-1); /* errno set */
- as->as_timeout = as->as_ctx->ac_nstimeout;
return (1);
}
@@ -584,7 +581,6 @@ tcp_write(struct async *as)
}
/* More data to write */
- as->as_timeout = as->as_ctx->ac_nstimeout;
return (1);
close: