]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: h2: don't close the connection is there are data left
authorWilly Tarreau <w@1wt.eu>
Tue, 7 Nov 2017 10:48:46 +0000 (11:48 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 7 Nov 2017 13:47:04 +0000 (14:47 +0100)
h2_detach() is called after a stream was closed, and it evaluates if it's
worth closing the connection. The issue there is that the connection is
closed too early in case there's demand for closing after the last stream,
even if some data remain in the mux. Let's change the condition to check
for this.

src/mux_h2.c

index 07a94bc518376b0397920175d0b5fb5f6831dae5..b241a5b53a6a49ab67d10e7a7f532add19b6fc19 100644 (file)
@@ -2210,11 +2210,12 @@ static void h2_detach(struct conn_stream *cs)
                 * or sent (as seen by last_sid >= 0). A timer should be armed
                 * to kill the connection after some idle time though.
                 */
-               if (eb_is_empty(&h2c->streams_by_id) &&
-                   (conn_xprt_read0_pending(h2c->conn) ||
-                    (h2c->conn->flags & CO_FL_ERROR) ||
+               if (eb_is_empty(&h2c->streams_by_id) &&     /* don't close if streams exist */
+                   ((h2c->conn->flags & CO_FL_ERROR) ||    /* errors close immediately */
                     (h2c->flags & H2_CF_GOAWAY_FAILED) ||
-                    (h2c->last_sid >= 0 && h2c->max_id >= h2c->last_sid))) {
+                    (!h2c->mbuf->o &&  /* mux buffer empty, also process clean events below */
+                     (conn_xprt_read0_pending(h2c->conn) ||
+                      (h2c->last_sid >= 0 && h2c->max_id >= h2c->last_sid))))) {
                        /* no more stream will come, kill it now */
                        h2_release(h2c->conn);
                }