X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=jcc.c;h=8f4e651582e6f312900d48d9ce3788364f1de6cf;hb=c2cd3ee0655ce225752874ed70674f28de4a1c45;hp=74fde67319b0c2f3a1f7097bed6857b2fb42dd24;hpb=32625bac711ac9601fea6a64ba278259f0eb89e9;p=privoxy.git diff --git a/jcc.c b/jcc.c index 74fde673..8f4e6515 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.336 2010/12/31 14:57:00 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.342 2011/03/03 14:44:00 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -1522,8 +1522,6 @@ static void chat(struct client_state *csp) int server_body; int ms_iis5_hack = 0; unsigned long long byte_count = 0; - int forwarded_connect_retries = 0; - int max_forwarded_connect_retries = csp->config->forwarded_connect_retries; const struct forward_spec *fwd; struct http_request *http; long len = 0; /* for buffer sizes (and negative error codes) */ @@ -1659,14 +1657,7 @@ static void chat(struct client_state *csp) } #endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ - while ((csp->server_connection.sfd = forwarded_connect(fwd, http, csp)) - && (errno == EINVAL) - && (forwarded_connect_retries++ < max_forwarded_connect_retries)) - { - log_error(LOG_LEVEL_ERROR, - "failed request #%u to connect to %s. Trying again.", - forwarded_connect_retries, http->hostport); - } + csp->server_connection.sfd = forwarded_connect(fwd, http, csp); if (csp->server_connection.sfd == JB_INVALID_SOCKET) { @@ -2401,7 +2392,7 @@ static void chat(struct client_state *csp) if (csp->content_length == 0) { /* - * If Privoxy didn't recalculate the Content-Lenght, + * If Privoxy didn't recalculate the Content-Length, * byte_count is still correct. */ csp->content_length = byte_count; @@ -2510,7 +2501,8 @@ static void serve(struct client_state *csp) && (((csp->flags & CSP_FLAG_SERVER_CONNECTION_KEEP_ALIVE) && !(csp->flags & CSP_FLAG_SERVER_SOCKET_TAINTED)) || (csp->flags & CSP_FLAG_CRUNCHED)) - && (csp->cfd != JB_INVALID_SOCKET); + && (csp->cfd != JB_INVALID_SOCKET) + && (csp->flags & CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE); if (continue_chatting && !(csp->flags & CSP_FLAG_CRUNCHED)) { @@ -2558,9 +2550,8 @@ static void serve(struct client_state *csp) && data_is_available(csp->cfd, (int)client_timeout) && socket_is_still_alive(csp->cfd)) { - log_error(LOG_LEVEL_CONNECT, "Client request arrived in " - "time or the client closed the connection on socket %d.", - csp->cfd); + log_error(LOG_LEVEL_CONNECT, + "Client request arrived in time on socket %d.", csp->cfd); prepare_csp_for_next_request(csp); } else @@ -3445,6 +3436,28 @@ static void listen_loop(void) } csp = &csp_list->csp; + log_error(LOG_LEVEL_CONNECT, "Listening for new connections ... "); + + if (!accept_connection(csp, bfd)) + { + log_error(LOG_LEVEL_CONNECT, "accept failed: %E"); + +#ifdef AMIGA + if(!childs) + { + exit(1); + } +#endif + freez(csp_list); + continue; + } + else + { + log_error(LOG_LEVEL_CONNECT, + "accepted connection from %s on socket %d", + csp->ip_addr_str, csp->cfd); + } + csp->flags |= CSP_FLAG_ACTIVE; csp->server_connection.sfd = JB_INVALID_SOCKET; @@ -3470,28 +3483,6 @@ static void listen_loop(void) bfd = bind_port_helper(config); } - log_error(LOG_LEVEL_CONNECT, "Listening for new connections ... "); - - if (!accept_connection(csp, bfd)) - { - log_error(LOG_LEVEL_CONNECT, "accept failed: %E"); - -#ifdef AMIGA - if(!childs) - { - exit(1); - } -#endif - freez(csp_list); - continue; - } - else - { - log_error(LOG_LEVEL_CONNECT, - "accepted connection from %s on socket %d", - csp->ip_addr_str, csp->cfd); - } - #ifdef FEATURE_TOGGLE if (global_toggle_state) #endif /* def FEATURE_TOGGLE */ @@ -3751,7 +3742,6 @@ static void listen_loop(void) #if defined(unix) freez(basedir); #endif - freez(configfile); #if defined(_WIN32) && !defined(_WIN_CONSOLE) /* Cleanup - remove taskbar icon etc. */