BUG/MEDIUM: mux-h1: Perform a connection shutdown when the h1c is released
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 27 Oct 2021 13:42:13 +0000 (15:42 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 3 Nov 2021 10:57:41 +0000 (11:57 +0100)
When the H1 connection is released, a connection shutdown is now performed.
If it was already performed when the stream was detached, this action has no
effect. But it is mandatory, when an idle H1C is released. Otherwise the
xprt and the socket shutdown is never perfmed. It is especially important
for SSL client connections, because it is the only way to perform a clean
SSL shutdown.

Without this patch, SSL_shutdown is never called, preventing, among other
things, the SSL session caching.

This patch depends on the commit "BUG/MINOR: mux-h1: Save shutdown mode if
the shutdown is delayed". It should be backported as far as 2.0.

(cherry picked from commit e76b4f055d8d6a5514f5c67e37ad7a8858b9eed2)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 37c42549234d4b3caab795af96fa8a9866629e7b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/mux_h1.c

index 0948313..e568229 100644 (file)
@@ -806,9 +806,12 @@ static void h1_release(struct h1c *h1c)
                        tasklet_free(h1c->wait_event.tasklet);
 
                h1s_destroy(h1c->h1s);
-               if (conn && h1c->wait_event.events != 0)
-                       conn->xprt->unsubscribe(conn, conn->xprt_ctx, h1c->wait_event.events,
-                           &h1c->wait_event);
+               if (conn) {
+                       if (h1c->wait_event.events != 0)
+                               conn->xprt->unsubscribe(conn, conn->xprt_ctx, h1c->wait_event.events,
+                                                       &h1c->wait_event);
+                       h1_shutw_conn(conn);
+               }
                pool_free(pool_head_h1c, h1c);
        }