From f5f677c707792ba5637716fdde07b9e551107163 Mon Sep 17 00:00:00 2001 From: Eric Faurot Date: Sun, 31 Mar 2013 19:42:11 +0000 Subject: Principle of least astonishment: implement nameserver retry/backoff as in the former resolver. --- lib/libc/asr/asr.c | 12 +++++++++--- lib/libc/asr/res_send_async.c | 6 +----- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'lib') 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 * @@ -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 * @@ -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: -- cgit v1.2.3