X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=jcc.c;h=c193898dc8aac357ea4980e5e6763989a8198733;hb=2c5ca2138671ea7d7d9fc02b2dbfd583f4c1c50b;hp=76a491be7ee26f65d23efe456d0caed2bae093c0;hpb=892b30a145ea051b5f9f5a46967175cede143a31;p=privoxy.git diff --git a/jcc.c b/jcc.c index 76a491be..c193898d 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.220 2009/02/04 18:29:07 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.224 2009/02/14 15:32:04 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -6,7 +6,7 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.220 2009/02/04 18:29:07 fabiankeil Exp $" * Purpose : Main file. Contains main() method, main loop, and * the main connection-handling function. * - * Copyright : Written by and Copyright (C) 2001-2008 the SourceForge + * Copyright : Written by and Copyright (C) 2001-2009 the SourceForge * Privoxy team. http://www.privoxy.org/ * * Based on the Internet Junkbuster originally written @@ -33,6 +33,24 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.220 2009/02/04 18:29:07 fabiankeil Exp $" * * Revisions : * $Log: jcc.c,v $ + * Revision 1.224 2009/02/14 15:32:04 fabiankeil + * Add the request URL to the timeout message in chat(). + * Suggested by Lee. + * + * Revision 1.223 2009/02/09 21:21:16 fabiankeil + * Now that init_log_module() is called earlier, call show_version() + * later on from main() directly so it doesn't get called for --help + * or --version. + * + * Revision 1.222 2009/02/08 12:56:51 fabiankeil + * Call initialize_mutexes() before init_log_module() again. + * Broken since r220, might be the cause of Lee's #2579448. + * + * Revision 1.221 2009/02/06 18:02:58 fabiankeil + * When dropping privileges, also give up membership in supplementary + * groups. Thanks to Matthias Drochner for reporting the problem, + * providing the initial patch and testing the final version. + * * Revision 1.220 2009/02/04 18:29:07 fabiankeil * Initialize the log module before parsing arguments. * Thanks to Matthias Drochner for the report. @@ -2154,8 +2172,38 @@ static int server_response_is_complete(struct client_state *csp, size_t content_ return (content_length_known && ((0 == csp->expected_content_length) || (csp->expected_content_length <= content_length))); } + + +/********************************************************************* + * + * Function : wait_for_alive_connections + * + * Description : Waits for alive connections to timeout. + * + * Parameters : N/A + * + * Returns : N/A + * + *********************************************************************/ +static void wait_for_alive_connections() +{ + int connections_alive = close_unusable_connections(); + + while (0 < connections_alive) + { + log_error(LOG_LEVEL_CONNECT, + "Waiting for %d connections to timeout.", + connections_alive); + sleep(60); + connections_alive = close_unusable_connections(); + } + + log_error(LOG_LEVEL_CONNECT, "No connections to wait for left."); + +} #endif /* FEATURE_CONNECTION_KEEP_ALIVE */ + /********************************************************************* * * Function : mark_server_socket_tainted @@ -2769,7 +2817,8 @@ static void chat(struct client_state *csp) if (n == 0) { - log_error(LOG_LEVEL_ERROR, "Didn't receive data in time."); + log_error(LOG_LEVEL_ERROR, + "Didn't receive data in time: %s", http->url); if ((byte_count == 0) && (http->ssl == 0)) { write_socket(csp->cfd, CONNECTION_TIMEOUT_RESPONSE, @@ -3226,6 +3275,7 @@ static void chat(struct client_state *csp) csp->content_length = byte_count; } +#ifdef FEATURE_CONNECTION_KEEP_ALIVE if ((csp->flags & CSP_FLAG_CONTENT_LENGTH_SET) && (csp->expected_content_length != byte_count)) { @@ -3234,40 +3284,13 @@ static void chat(struct client_state *csp) byte_count, csp->expected_content_length); mark_server_socket_tainted(csp); } +#endif log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 %d", csp->ip_addr_str, http->ocmd, csp->content_length); } -/********************************************************************* - * - * Function : wait_for_alive_connections - * - * Description : Waits for alive connections to timeout. - * - * Parameters : N/A - * - * Returns : N/A - * - *********************************************************************/ -static void wait_for_alive_connections() -{ - int connections_alive = close_unusable_connections(); - - while (0 < connections_alive) - { - log_error(LOG_LEVEL_CONNECT, - "Waiting for %d connections to timeout.", - connections_alive); - sleep(60); - connections_alive = close_unusable_connections(); - } - - log_error(LOG_LEVEL_CONNECT, "No connections to wait for left."); - -} - /********************************************************************* * * Function : serve @@ -3571,8 +3594,11 @@ int main(int argc, const char *argv[]) #endif ; + /* Prepare mutexes if supported and necessary. */ + initialize_mutexes(); + /* Enable logging until further notice. */ - init_log_module(Argv[0]); + init_log_module(); /* * Parse the command line arguments @@ -3685,6 +3711,8 @@ int main(int argc, const char *argv[]) } /* -END- while (more arguments) */ + show_version(Argv[0]); + #if defined(unix) if ( *configfile != '/' ) { @@ -3727,9 +3755,6 @@ int main(int argc, const char *argv[]) InitWin32(); #endif - /* Prepare mutexes if supported and necessary. */ - initialize_mutexes(); - random_seed = (unsigned int)time(NULL); #ifdef HAVE_RANDOM srandom(random_seed);