Streamline socks5_connect() slightly
[privoxy.git] / gateway.c
index 9ab19d5..b65991a 100644 (file)
--- a/gateway.c
+++ b/gateway.c
@@ -1,4 +1,4 @@
-const char gateway_rcs[] = "$Id: gateway.c,v 1.77 2011/09/06 18:46:17 fabiankeil Exp $";
+const char gateway_rcs[] = "$Id: gateway.c,v 1.81 2011/10/23 11:21:09 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/gateway.c,v $
@@ -338,16 +338,12 @@ void forget_connection(jb_socket sfd)
             sfd, reusable_connection[slot].host,
             reusable_connection[slot].port, slot);
          mark_connection_closed(&reusable_connection[slot]);
-         privoxy_mutex_unlock(&connection_reuse_mutex);
-
-         return;
+         break;
       }
    }
 
-   log_error(LOG_LEVEL_CONNECT,
-      "Socket %d already forgotten or never remembered.", sfd);
-
    privoxy_mutex_unlock(&connection_reuse_mutex);
+
 }
 #endif /* def FEATURE_CONNECTION_SHARING */
 
@@ -947,7 +943,7 @@ static jb_socket socks5_connect(const struct forward_spec *fwd,
 {
    int err = 0;
    char cbuf[300];
-   char sbuf[30];
+   char sbuf[10];
    size_t client_pos = 0;
    int server_size = 0;
    size_t hostlen = 0;
@@ -1094,20 +1090,11 @@ static jb_socket socks5_connect(const struct forward_spec *fwd,
    }
 
    server_size = read_socket(sfd, sbuf, sizeof(sbuf));
-   if (server_size < 3)
+   if (server_size != sizeof(sbuf))
    {
       errstr = "SOCKS5 negotiation read failed";
-      err = 1;
    }
-   else if (server_size > 20)
-   {
-      /* This is somewhat unexpected but doesn't really matter. */
-      log_error(LOG_LEVEL_CONNECT, "socks5_connect: read %d bytes "
-         "from socks server. Would have accepted up to %d.",
-         server_size, sizeof(sbuf));
-   }
-
-   if (!err)
+   else
    {
       if (sbuf[0] != '\x05')
       {
@@ -1129,7 +1116,7 @@ static jb_socket socks5_connect(const struct forward_spec *fwd,
 
    assert(errstr != NULL);
    csp->error_message = strdup(errstr);
-   log_error(LOG_LEVEL_CONNECT, "socks5_connect: %s", errstr);
+   log_error(LOG_LEVEL_CONNECT, "socks5_connect: %s: %N", errstr, server_size, sbuf);
    close_socket(sfd);
    errno = EINVAL;