summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2006-04-20 09:48:00 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2006-04-20 09:48:00 +0000
commit6441d0775e63df383c38c49aeaa0857bb6753460 (patch)
tree0d632c728f572cf56f2d633178195b804e819f84 /usr.bin
parent78d5ccc3b1d2431c62aeb1829b4211274c580799 (diff)
simplify; ok djm@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/sshconnect.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/usr.bin/ssh/sshconnect.c b/usr.bin/ssh/sshconnect.c
index d5295043b3f..a0e6725f0bc 100644
--- a/usr.bin/ssh/sshconnect.c
+++ b/usr.bin/ssh/sshconnect.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshconnect.c,v 1.180 2006/03/25 13:17:02 djm Exp $ */
+/* $OpenBSD: sshconnect.c,v 1.181 2006/04/20 09:47:59 markus Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -300,17 +300,14 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
fatal("%s: %.100s: %s", __progname, host,
gai_strerror(gaierr));
- /*
- * Try to connect several times. On some machines, the first time
- * will sometimes fail. In general socket code appears to behave
- * quite magically on many machines.
- */
- for (attempt = 0; ;) {
+ for (attempt = 0; attempt < connection_attempts; attempt++) {
if (attempt > 0)
debug("Trying again...");
- /* Loop through addresses for this host, and try each one in
- sequence until the connection succeeds. */
+ /*
+ * Loop through addresses for this host, and try each one in
+ * sequence until the connection succeeds.
+ */
for (ai = aitop; ai; ai = ai->ai_next) {
if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
continue;
@@ -337,21 +334,13 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
} else {
debug("connect to address %s port %s: %s",
ntop, strport, strerror(errno));
- /*
- * Close the failed socket; there appear to
- * be some problems when reusing a socket for
- * which connect() has already returned an
- * error.
- */
close(sock);
+ sock = -1;
}
}
- if (ai)
+ if (sock != -1)
break; /* Successful connection. */
- attempt++;
- if (attempt >= connection_attempts)
- break;
/* Sleep a moment before retrying. */
sleep(1);
}
@@ -359,7 +348,7 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
freeaddrinfo(aitop);
/* Return failure if we didn't get a successful connection. */
- if (attempt >= connection_attempts) {
+ if (sock == -1) {
error("ssh: connect to host %s port %s: %s",
host, strport, strerror(errno));
return (-1);