From 296e625ee14b5b4725d8dddec7483ce796cc488b Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Wed, 10 Mar 2021 17:50:53 +0100 Subject: [PATCH] handle_established_connection(): Skip the poll()/select() calls ... if TLS data is pending on the server socket. The TLS library may have already consumed all the data from the server response in which case poll() and select() will not detect that data is available to be read. Fixes SF bug #926 reported by Wen Yue. --- jcc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/jcc.c b/jcc.c index 648fd455..d8840b60 100644 --- a/jcc.c +++ b/jcc.c @@ -3085,6 +3085,18 @@ static void handle_established_connection(struct client_state *csp) for (;;) { +#ifdef FEATURE_HTTPS_INSPECTION + if (server_use_ssl(csp) && is_ssl_pending(&(csp->ssl_server_attr))) + { + /* + * It's possible that the TLS library already consumed all the + * data the server intends to send. If that happens poll() and + * select() will no longer see the data as available so we have + * to skip the calls. + */ + goto server_wants_to_talk; + } +#endif #ifndef HAVE_POLL FD_ZERO(&rfds); #ifdef FEATURE_CONNECTION_KEEP_ALIVE @@ -3358,6 +3370,9 @@ static void handle_established_connection(struct client_state *csp) if (FD_ISSET(csp->server_connection.sfd, &rfds)) #endif /* HAVE_POLL */ { +#ifdef FEATURE_HTTPS_INSPECTION + server_wants_to_talk: +#endif #ifdef FEATURE_CONNECTION_KEEP_ALIVE /* * If we are buffering content, we don't want to eat up to -- 2.39.2