From: Fabian Keil Date: Tue, 22 Sep 2020 08:31:20 +0000 (+0200) Subject: serve(): Close the client socket before closing the server socket X-Git-Tag: v_3_0_29~96 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=0c82acb57e75e9a1463b4b6b56e7709752c63f89 serve(): Close the client socket before closing the server socket When using OpenSSL, closing the server socket sometimes takes a long time so make sure this does not delay the closing of the client socket. While this is a work around, it doesn't hurt and can be kept once the OpenSSL issue is fixed in follow-up commits. --- diff --git a/jcc.c b/jcc.c index d1ae1eec..4119e4a5 100644 --- a/jcc.c +++ b/jcc.c @@ -4503,6 +4503,20 @@ static void serve(struct client_state *csp) chat(csp); #endif /* def FEATURE_CONNECTION_KEEP_ALIVE */ + if (csp->cfd != JB_INVALID_SOCKET) + { + log_error(LOG_LEVEL_CONNECT, "Closing client socket %d. " + "Keep-alive: %u. Socket alive: %u. Data available: %u. " + "Configuration file change detected: %u. Requests received: %u.", + csp->cfd, 0 != (csp->flags & CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE), + socket_is_still_alive(csp->cfd), data_is_available(csp->cfd, 0), + config_file_change_detected, csp->requests_received_total); +#ifdef FEATURE_HTTPS_INSPECTION + close_client_ssl_connection(csp); +#endif + drain_and_close_socket(csp->cfd); + } + if (csp->server_connection.sfd != JB_INVALID_SOCKET) { #ifdef FEATURE_CONNECTION_SHARING @@ -4523,20 +4537,6 @@ static void serve(struct client_state *csp) mark_connection_closed(&csp->server_connection); #endif - if (csp->cfd != JB_INVALID_SOCKET) - { - log_error(LOG_LEVEL_CONNECT, "Closing client socket %d. " - "Keep-alive: %u. Socket alive: %u. Data available: %u. " - "Configuration file change detected: %u. Requests received: %u.", - csp->cfd, 0 != (csp->flags & CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE), - socket_is_still_alive(csp->cfd), data_is_available(csp->cfd, 0), - config_file_change_detected, csp->requests_received_total); -#ifdef FEATURE_HTTPS_INSPECTION - close_client_ssl_connection(csp); -#endif - drain_and_close_socket(csp->cfd); - } - free_csp_resources(csp); csp->flags &= ~CSP_FLAG_ACTIVE;