X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=jcc.c;h=3bbacd15fba45e41a37357f544d0471ea5a36480;hp=1026672611cd3d79f32fdac8d6b67dc70607527f;hb=84ee09b204158e3b3e4062f5d4bb3faccf7a4e0c;hpb=1229c1bd3d1494ed3eb583f64c46a7b19e3cce19 diff --git a/jcc.c b/jcc.c index 10266726..3bbacd15 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.463 2017/06/26 12:12:55 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.468 2017/08/12 09:33:25 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -105,6 +105,7 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.463 2017/06/26 12:12:55 fabiankeil Exp $" # ifndef FD_ZERO # include # endif +#warning poll() appears to be unavailable. Your platform will become unsupported in the future. #endif /* HAVE_POLL */ #endif @@ -1963,8 +1964,7 @@ static int send_http_request(struct client_state *csp) * Returns : Nothing. * *********************************************************************/ -static void handle_established_connection(struct client_state *csp, - const struct forward_spec *fwd) +static void handle_established_connection(struct client_state *csp) { char *receive_buffer; char *hdr; @@ -2116,8 +2116,8 @@ static void handle_established_connection(struct client_state *csp, if (n == 0) { - log_error(LOG_LEVEL_ERROR, - "Didn't receive data in time: %s", http->url); + log_error(LOG_LEVEL_CONNECT, "Socket timeout %d reached: %s", + csp->config->socket_timeout, http->url); if ((byte_count == 0) && (http->ssl == 0)) { send_crunch_response(csp, error_response(csp, "connection-timeout")); @@ -2283,7 +2283,7 @@ static void handle_established_connection(struct client_state *csp, { log_error(LOG_LEVEL_ERROR, "read from: %s failed: %E", http->host); - if (http->ssl && (fwd->forward_host == NULL)) + if (http->ssl && (csp->fwd == NULL)) { /* * Just hang up. We already confirmed the client's CONNECT @@ -3031,7 +3031,7 @@ static void chat(struct client_state *csp) /* XXX: should the time start earlier for optimistically sent data? */ csp->server_connection.request_sent = time(NULL); - handle_established_connection(csp, fwd); + handle_established_connection(csp); } @@ -3068,6 +3068,7 @@ extern int fuzz_server_response(struct client_state *csp, char *fuzz_input_file) fuzz_input_file); } } + csp->fwd = &fwd; csp->content_type |= CT_GIF; csp->action->flags |= ACTION_DEANIMATE; csp->action->string[ACTION_STRING_DEANIMATE] = "last"; @@ -3088,7 +3089,7 @@ extern int fuzz_server_response(struct client_state *csp, char *fuzz_input_file) cgi_init_error_messages(); - handle_established_connection(csp, &fwd); + handle_established_connection(csp); return 0; } @@ -3386,6 +3387,8 @@ static void serve(struct client_state *csp) drain_and_close_socket(csp->cfd); } + free_csp_resources(csp); + csp->flags &= ~CSP_FLAG_ACTIVE; } @@ -4294,6 +4297,12 @@ static void listen_loop(void) jb_socket bfds[MAX_LISTENING_SOCKETS]; struct configuration_spec *config; unsigned int active_threads = 0; +#if defined(FEATURE_PTHREAD) + pthread_attr_t attrs; + + pthread_attr_init(&attrs); + pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED); +#endif config = load_config(); @@ -4449,14 +4458,10 @@ static void listen_loop(void) #define SELECTED_ONE_OPTION { pthread_t the_thread; - pthread_attr_t attrs; - pthread_attr_init(&attrs); - pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED); errno = pthread_create(&the_thread, &attrs, (void * (*)(void *))serve, csp); child_id = errno ? -1 : 0; - pthread_attr_destroy(&attrs); } #endif @@ -4621,6 +4626,10 @@ static void listen_loop(void) } } +#if defined(FEATURE_PTHREAD) + pthread_attr_destroy(&attrs); +#endif + /* NOTREACHED unless FEATURE_GRACEFUL_TERMINATION is defined */ /* Clean up. Aim: free all memory (no leaks) */