Change ssplit()'s fourth parameter from int to the proper size_t
[privoxy.git] / jbsockets.c
index 680d083..5691988 100644 (file)
@@ -1,4 +1,4 @@
-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.98 2011/03/27 14:08:35 fabiankeil Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.101 2011/05/03 09:55:35 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
@@ -158,14 +158,18 @@ jb_socket connect_to(const char *host, int portnum, struct client_state *csp)
       fd = no_rfc2553_connect_to(host, portnum, csp);
 #endif
       if ((fd != JB_INVALID_SOCKET) || (errno == EINVAL)
+         || (csp->fwd == NULL)
          || ((csp->fwd->forward_host == NULL) && (csp->fwd->type == SOCKS_NONE)))
       {
          break;
       }
       forwarded_connect_retries++;
-      log_error(LOG_LEVEL_ERROR,
-         "Attempt %d of %d to connect to %s failed. Trying again.",
-         forwarded_connect_retries, csp->config->forwarded_connect_retries, host);
+      if (csp->config->forwarded_connect_retries != 0)
+      {
+         log_error(LOG_LEVEL_ERROR,
+            "Attempt %d of %d to connect to %s failed. Trying again.",
+            forwarded_connect_retries, csp->config->forwarded_connect_retries, host);
+      }
 
    } while (forwarded_connect_retries < csp->config->forwarded_connect_retries);
 
@@ -346,8 +350,17 @@ static jb_socket rfc2553_connect_to(const char *host, int portnum, struct client
                /* Connection established, no need to try other addresses. */
                break;
             }
-            log_error(LOG_LEVEL_CONNECT, "Could not connect to [%s]:%s: %s.",
-               csp->http->host_ip_addr_str, service, strerror(socket_error));
+            if (rp->ai_next != NULL)
+            {
+               /*
+                * There's another address we can try, so log that this
+                * one didn't work out. If the last one fails, too,
+                * it will get logged outside the loop body so we don't
+                * have to mention it here.
+                */
+               log_error(LOG_LEVEL_CONNECT, "Could not connect to [%s]:%s: %s.",
+                  csp->http->host_ip_addr_str, service, strerror(socket_error));
+            }
          }
          else
          {