Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 01 Mar 2006 00:28:14 +0900
From:      Hajimu UMEMOTO <ume@freebsd.org>
To:        Yar Tikhiy <yar@comp.chem.msu.su>
Cc:        freebsd-stable@freebsd.org, freebsd-stable-local@be-well.ilk.org, dwmalone@maths.tcd.ie, Rostislav Krasny <rosti.bsd@gmail.com>, des@des.no, mak@ll.mit.edu, MH@kernel32.de
Subject:   Re: SSH login takes very long time...sometimes
Message-ID:  <ygeveuz33ld.wl%ume@mahoroba.org>
In-Reply-To: <20060227151954.GV6435@comp.chem.msu.su>
References:  <20060218012029.e146e2ff.rosti.bsd@gmail.com> <20060219104912.GB20500@comp.chem.msu.su> <20060219225701.0e3e244b.rosti.bsd@gmail.com> <20060221165959.GB77513@comp.chem.msu.su> <20060222024430.ad4b5c60.rosti.bsd@gmail.com> <yge1wxvz5ha.wl%ume@mahoroba.org> <20060223235727.33cddb13.rosti.bsd@gmail.com> <ygefym98o7i.wl%ume@mahoroba.org> <20060224155153.f7da1a52.rosti.bsd@gmail.com> <ygewtfkelbu.wl%ume@mahoroba.org> <20060227151954.GV6435@comp.chem.msu.su>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

>>>>> On Mon, 27 Feb 2006 18:19:54 +0300
>>>>> Yar Tikhiy <yar@comp.chem.msu.su> said:

yar> I finally spared some time to test your recent changes and found
yar> that the resolver still would retry using the first, and only the
yar> first, domain on the `search' list when the nameserver was down,
yar> which effectively led to another kind of request doubling.

yar> A similar effect was observed when a `domain' line was specified
yar> in resolv.conf in place of `search'.

yar> Is there a real reason to retry with a different domain when the
yar> nameserver doesn't respond at all?

It seems yet another issue.  The errors returned by res_querydomain()
are not handled uniformity.  Please try following patch:

Index: lib/libc/net/getaddrinfo.c
diff -u -p lib/libc/net/getaddrinfo.c.orig lib/libc/net/getaddrinfo.c
--- lib/libc/net/getaddrinfo.c.orig	Sun Feb 26 16:04:41 2006
+++ lib/libc/net/getaddrinfo.c	Tue Feb 28 16:21:15 2006
@@ -2440,6 +2440,17 @@ res_searchN(name, target)
 		ret = res_querydomainN(name, NULL, target);
 		if (ret > 0 || trailing_dot)
 			return (ret);
+		if (errno == ECONNREFUSED) {
+			h_errno = TRY_AGAIN;
+			return (-1);
+		}
+		switch (h_errno) {
+		case NO_DATA:
+		case HOST_NOT_FOUND:
+			break;
+		default:
+			return (-1);
+		}
 		saved_herrno = h_errno;
 		tried_as_is++;
 	}
@@ -2515,6 +2526,14 @@ res_searchN(name, target)
 		}
 	}
 
+	switch (h_errno) {
+	case NO_DATA:
+	case HOST_NOT_FOUND:
+		break;
+	default:
+		goto giveup;
+	}
+
 	/*
 	 * If the query has not already been tried as is then try it
 	 * unless RES_NOTLDQUERY is set and there were no dots.
@@ -2534,6 +2553,7 @@ res_searchN(name, target)
 	 * else send back meaningless h_errno, that being the one from
 	 * the last DNSRCH we did.
 	 */
+giveup:
 	if (saved_herrno != -1)
 		h_errno = saved_herrno;
 	else if (got_nodata)
Index: lib/libc/net/res_query.c
diff -u -p lib/libc/net/res_query.c.orig lib/libc/net/res_query.c
--- lib/libc/net/res_query.c.orig	Sun Feb 26 16:04:41 2006
+++ lib/libc/net/res_query.c	Tue Feb 28 16:14:23 2006
@@ -229,6 +229,17 @@ res_search(name, class, type, answer, an
 		ret = res_querydomain(name, NULL, class, type, answer, anslen);
 		if (ret > 0 || trailing_dot)
 			return (ret);
+		if (errno == ECONNREFUSED) {
+			h_errno = TRY_AGAIN;
+			return (-1);
+		}
+		switch (h_errno) {
+		case NO_DATA:
+		case HOST_NOT_FOUND:
+			break;
+		default:
+			return (-1);
+		}
 		saved_herrno = h_errno;
 		tried_as_is++;
 	}
@@ -318,6 +329,14 @@ res_search(name, class, type, answer, an
 		}
 	}
 
+	switch (h_errno) {
+	case NO_DATA:
+	case HOST_NOT_FOUND:
+		break;
+	default:
+		goto giveup;
+	}
+
 	/*
 	 * If the query has not already been tried as is then try it
 	 * unless RES_NOTLDQUERY is set and there were no dots.
@@ -336,6 +355,7 @@ res_search(name, class, type, answer, an
 	 * else send back meaningless h_errno, that being the one from
 	 * the last DNSRCH we did.
 	 */
+giveup:
 	if (saved_herrno != -1)
 		h_errno = saved_herrno;
 	else if (got_nodata)


Sincerely,

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume@mahoroba.org  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ygeveuz33ld.wl%ume>