X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=jcc.c;h=e1a9ab6b04ff9c9d6b0d64029570e9f928c256fd;hb=24ae510461a9161c320c6c51db9f3343da681793;hp=0b376c13be34a1db584d520d8f4c9abcbe080c4d;hpb=f1bdfcc8708cb7ab462d36ab2878add957a5f5fa;p=privoxy.git diff --git a/jcc.c b/jcc.c index 0b376c13..e1a9ab6b 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.335 2010/12/26 16:20:08 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.338 2011/01/02 12:17:03 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -1949,7 +1949,14 @@ static void chat(struct client_state *csp) if (FD_ISSET(csp->server_connection.sfd, &rfds)) { #ifdef FEATURE_CONNECTION_KEEP_ALIVE - if (!socket_is_still_alive(csp->cfd)) + /* + * If we are buffering content, we don't want to eat up to + * buffer-limit bytes if the client no longer cares about them. + * If we aren't buffering, however, a dead client socket will be + * noticed pretty much right away anyway, so we can reduce the + * overhead by skipping the check. + */ + if (buffer_and_filter_content && !socket_is_still_alive(csp->cfd)) { #ifdef _WIN32 log_error(LOG_LEVEL_CONNECT, @@ -2551,9 +2558,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 @@ -3438,6 +3444,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; @@ -3463,28 +3491,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 */