summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--sshconnect.c29
2 files changed, 13 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 8131cd6cf..552e780ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -52,6 +52,9 @@
52 replace the last non-sig_atomic_t flag used in a signal handler with a 52 replace the last non-sig_atomic_t flag used in a signal handler with a
53 sig_atomic_t, unfortunately with some knock-on effects in other (non- 53 sig_atomic_t, unfortunately with some knock-on effects in other (non-
54 signal) contexts in which it is used; ok markus@ 54 signal) contexts in which it is used; ok markus@
55 - markus@cvs.openbsd.org 2006/04/20 09:47:59
56 [sshconnect.c]
57 simplify; ok djm@
55 58
5620060421 5920060421
57 - (djm) [Makefile.in configure.ac session.c sshpty.c] 60 - (djm) [Makefile.in configure.ac session.c sshpty.c]
@@ -4563,4 +4566,4 @@
4563 - (djm) Trim deprecated options from INSTALL. Mention UsePAM 4566 - (djm) Trim deprecated options from INSTALL. Mention UsePAM
4564 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu 4567 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
4565 4568
4566$Id: ChangeLog,v 1.4312 2006/04/23 02:08:37 djm Exp $ 4569$Id: ChangeLog,v 1.4313 2006/04/23 02:08:59 djm Exp $
diff --git a/sshconnect.c b/sshconnect.c
index 5cf107794..5f2ad1cfa 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect.c,v 1.180 2006/03/25 13:17:02 djm Exp $ */ 1/* $OpenBSD: sshconnect.c,v 1.181 2006/04/20 09:47:59 markus Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -306,17 +306,14 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
306 fatal("%s: %.100s: %s", __progname, host, 306 fatal("%s: %.100s: %s", __progname, host,
307 gai_strerror(gaierr)); 307 gai_strerror(gaierr));
308 308
309 /* 309 for (attempt = 0; attempt < connection_attempts; attempt++) {
310 * Try to connect several times. On some machines, the first time
311 * will sometimes fail. In general socket code appears to behave
312 * quite magically on many machines.
313 */
314 for (attempt = 0; ;) {
315 if (attempt > 0) 310 if (attempt > 0)
316 debug("Trying again..."); 311 debug("Trying again...");
317 312
318 /* Loop through addresses for this host, and try each one in 313 /*
319 sequence until the connection succeeds. */ 314 * Loop through addresses for this host, and try each one in
315 * sequence until the connection succeeds.
316 */
320 for (ai = aitop; ai; ai = ai->ai_next) { 317 for (ai = aitop; ai; ai = ai->ai_next) {
321 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) 318 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
322 continue; 319 continue;
@@ -343,21 +340,13 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
343 } else { 340 } else {
344 debug("connect to address %s port %s: %s", 341 debug("connect to address %s port %s: %s",
345 ntop, strport, strerror(errno)); 342 ntop, strport, strerror(errno));
346 /*
347 * Close the failed socket; there appear to
348 * be some problems when reusing a socket for
349 * which connect() has already returned an
350 * error.
351 */
352 close(sock); 343 close(sock);
344 sock = -1;
353 } 345 }
354 } 346 }
355 if (ai) 347 if (sock != -1)
356 break; /* Successful connection. */ 348 break; /* Successful connection. */
357 349
358 attempt++;
359 if (attempt >= connection_attempts)
360 break;
361 /* Sleep a moment before retrying. */ 350 /* Sleep a moment before retrying. */
362 sleep(1); 351 sleep(1);
363 } 352 }
@@ -365,7 +354,7 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
365 freeaddrinfo(aitop); 354 freeaddrinfo(aitop);
366 355
367 /* Return failure if we didn't get a successful connection. */ 356 /* Return failure if we didn't get a successful connection. */
368 if (attempt >= connection_attempts) { 357 if (sock == -1) {
369 error("ssh: connect to host %s port %s: %s", 358 error("ssh: connect to host %s port %s: %s",
370 host, strport, strerror(errno)); 359 host, strport, strerror(errno));
371 return (-1); 360 return (-1);