From: Fabian Keil Date: Mon, 23 Jul 2012 12:39:12 +0000 (+0000) Subject: Do not confuse a client hanging up with a connection time out X-Git-Tag: v_3_0_20~320 X-Git-Url: http://www.privoxy.org/gitweb/-%22http:/sourceforge.net/sflogo.php?a=commitdiff_plain;h=8c144430bd5b07ee088dcc01f3799b488219954a;p=privoxy.git Do not confuse a client hanging up with a connection time out If a client closes its side of the connection without sending a request line, do not send the CLIENT_CONNECTION_TIMEOUT_RESPONSE, but report the condition properly. This was reproducible with (for example): false | nc privoxy-jail 8118 --- diff --git a/jcc.c b/jcc.c index 81a6938e..5d8bff17 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.377 2012/03/09 16:24:36 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.378 2012/03/10 11:08:10 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -1193,11 +1193,20 @@ static char *get_request_line(struct client_state *csp) { if (!data_is_available(csp->cfd, csp->config->socket_timeout)) { - log_error(LOG_LEVEL_CONNECT, - "Stopped waiting for the request line. Timeout: %d.", - csp->config->socket_timeout); - write_socket(csp->cfd, CLIENT_CONNECTION_TIMEOUT_RESPONSE, - strlen(CLIENT_CONNECTION_TIMEOUT_RESPONSE)); + if (socket_is_still_alive(csp->cfd)) + { + log_error(LOG_LEVEL_CONNECT, + "No request line on socket %d received in time. Timeout: %d.", + csp->cfd, csp->config->socket_timeout); + write_socket(csp->cfd, CLIENT_CONNECTION_TIMEOUT_RESPONSE, + strlen(CLIENT_CONNECTION_TIMEOUT_RESPONSE)); + } + else + { + log_error(LOG_LEVEL_CONNECT, + "The client side of the connection on socket %d got " + "closed without sending a complete request line.", csp->cfd); + } return NULL; }