From: Fabian Keil <fk@fabiankeil.de>
Date: Sat, 6 Mar 2021 10:52:10 +0000 (+0100)
Subject: serve(): Close the client socket as well
X-Git-Tag: v_3_0_33~106^2~8
X-Git-Url: http://www.privoxy.org/gitweb/faq/static/@default-cgi@send-stylesheet?a=commitdiff_plain;h=2d8fefc484274b740933541778ae7ce1ae1045e7;p=privoxy.git

serve(): Close the client socket as well

... if the server socket for an inspected connection has been closed.

Privoxy currently can't establish a new server connection
when the client socket is reused and would drop the connection
in continue_https_chat() anyway.
---

diff --git a/jcc.c b/jcc.c
index ee408b3c..cd7bf710 100644
--- a/jcc.c
+++ b/jcc.c
@@ -4847,6 +4847,22 @@ static void serve(struct client_state *csp)
 #endif
             close_socket(csp->server_connection.sfd);
             mark_connection_closed(&csp->server_connection);
+#ifdef FEATURE_HTTPS_INSPECTION
+            if (continue_chatting && client_use_ssl(csp))
+            {
+               /*
+                * Close the client socket as well as Privoxy currently
+                * can't establish a new server connection when the client
+                * socket is reused and would drop the connection in
+                * continue_https_chat() anyway.
+                */
+               continue_chatting = 0;
+               csp->flags &= ~CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE;
+               log_error(LOG_LEVEL_CONNECT,
+                  "Client socket %d is no longer usable. "
+                  "The server socket has been closed.", csp->cfd);
+            }
+#endif
          }
       }