summaryrefslogtreecommitdiffstats
path: root/usr.bin/whois
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2001-06-01 13:43:20 +0000
committerume <ume@FreeBSD.org>2001-06-01 13:43:20 +0000
commit8888e65159e8b4c46c487a1f7a3ed9a036f43f1e (patch)
treebc4b272144c067b67a288013ea116bed468396b9 /usr.bin/whois
parent047342f08c1b586e36e0c3255a069373525b9e6f (diff)
downloadFreeBSD-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.c15
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");
}
OpenPOWER on IntegriCloud