diff options
author | ume <ume@FreeBSD.org> | 2001-06-01 13:43:20 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2001-06-01 13:43:20 +0000 |
commit | 8888e65159e8b4c46c487a1f7a3ed9a036f43f1e (patch) | |
tree | bc4b272144c067b67a288013ea116bed468396b9 /usr.bin/whois | |
parent | 047342f08c1b586e36e0c3255a069373525b9e6f (diff) | |
download | FreeBSD-src-8888e65159e8b4c46c487a1f7a3ed9a036f43f1e.zip FreeBSD-src-8888e65159e8b4c46c487a1f7a3ed9a036f43f1e.tar.gz |
Do retry next entry in addrinfo during connect.
MFC after: 1 week
Diffstat (limited to 'usr.bin/whois')
-rw-r--r-- | usr.bin/whois/whois.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.bin/whois/whois.c b/usr.bin/whois/whois.c index 3e31a65..d4452c0 100644 --- a/usr.bin/whois/whois.c +++ b/usr.bin/whois/whois.c @@ -220,12 +220,17 @@ whois(name, res, flags) size_t len; int s, nomatch; - s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (s < 0) { - err(EX_OSERR, "socket"); + for (; res; res = res->ai_next) { + s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); + if (s < 0) { + continue; + } + if (connect(s, res->ai_addr, res->ai_addrlen) == 0) { + break; + } + close(s); } - - if (connect(s, res->ai_addr, res->ai_addrlen) < 0) { + if (res == NULL) { err(EX_OSERR, "connect"); } |