- markus@cvs.openbsd.org 2006/04/20 09:47:59
[sshconnect.c] simplify; ok djm@
This commit is contained in:
parent
97c91f688f
commit
56e5e6ad11
|
@ -52,6 +52,9 @@
|
||||||
replace the last non-sig_atomic_t flag used in a signal handler with a
|
replace the last non-sig_atomic_t flag used in a signal handler with a
|
||||||
sig_atomic_t, unfortunately with some knock-on effects in other (non-
|
sig_atomic_t, unfortunately with some knock-on effects in other (non-
|
||||||
signal) contexts in which it is used; ok markus@
|
signal) contexts in which it is used; ok markus@
|
||||||
|
- markus@cvs.openbsd.org 2006/04/20 09:47:59
|
||||||
|
[sshconnect.c]
|
||||||
|
simplify; ok djm@
|
||||||
|
|
||||||
20060421
|
20060421
|
||||||
- (djm) [Makefile.in configure.ac session.c sshpty.c]
|
- (djm) [Makefile.in configure.ac session.c sshpty.c]
|
||||||
|
@ -4563,4 +4566,4 @@
|
||||||
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
|
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
|
||||||
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
|
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.4312 2006/04/23 02:08:37 djm Exp $
|
$Id: ChangeLog,v 1.4313 2006/04/23 02:08:59 djm Exp $
|
||||||
|
|
29
sshconnect.c
29
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>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||||
|
@ -306,17 +306,14 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
|
||||||
fatal("%s: %.100s: %s", __progname, host,
|
fatal("%s: %.100s: %s", __progname, host,
|
||||||
gai_strerror(gaierr));
|
gai_strerror(gaierr));
|
||||||
|
|
||||||
/*
|
for (attempt = 0; attempt < connection_attempts; attempt++) {
|
||||||
* 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; ;) {
|
|
||||||
if (attempt > 0)
|
if (attempt > 0)
|
||||||
debug("Trying again...");
|
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) {
|
for (ai = aitop; ai; ai = ai->ai_next) {
|
||||||
if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
|
if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
|
||||||
continue;
|
continue;
|
||||||
|
@ -343,21 +340,13 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
|
||||||
} else {
|
} else {
|
||||||
debug("connect to address %s port %s: %s",
|
debug("connect to address %s port %s: %s",
|
||||||
ntop, strport, strerror(errno));
|
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);
|
close(sock);
|
||||||
|
sock = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ai)
|
if (sock != -1)
|
||||||
break; /* Successful connection. */
|
break; /* Successful connection. */
|
||||||
|
|
||||||
attempt++;
|
|
||||||
if (attempt >= connection_attempts)
|
|
||||||
break;
|
|
||||||
/* Sleep a moment before retrying. */
|
/* Sleep a moment before retrying. */
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
@ -365,7 +354,7 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
|
||||||
freeaddrinfo(aitop);
|
freeaddrinfo(aitop);
|
||||||
|
|
||||||
/* Return failure if we didn't get a successful connection. */
|
/* 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",
|
error("ssh: connect to host %s port %s: %s",
|
||||||
host, strport, strerror(errno));
|
host, strport, strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
Loading…
Reference in New Issue