[BACK]Return to sshconnect.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/sshconnect.c between version 1.180 and 1.181

version 1.180, 2006/03/25 13:17:02 version 1.181, 2006/04/20 09:47:59
Line 300 
Line 300 
                 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;
Line 337 
Line 334 
                         } 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);
         }          }
Line 359 
Line 348 
         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);

Legend:
Removed from v.1.180  
changed lines
  Added in v.1.181