SSH login takes very long time...sometimes

Hajimu UMEMOTO ume at freebsd.org
Tue Feb 28 07:30:33 PST 2006


Hi,

>>>>> On Mon, 27 Feb 2006 18:19:54 +0300
>>>>> Yar Tikhiy <yar at 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 at mahoroba.org  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/


More information about the freebsd-stable mailing list