]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux: Make sure every string is woken up after the handshake.
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 23 Nov 2017 17:25:47 +0000 (18:25 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 23 Nov 2017 18:35:42 +0000 (19:35 +0100)
In case any stream was waiting for the handshake after receiving early data,
we have to wake all of them. Do so by making the mux responsible for
removing the CO_FL_EARLY_DATA flag after all of them are woken up, instead
of doing it in si_cs_wake_cb(), which would then only work for the first one.
This makes wait_for_handshake work with HTTP/2.

src/mux_h2.c
src/mux_pt.c
src/stream_interface.c

index 57f1dfe0a923fcdfcc5d34cc6fe246dbab3f0304..43248f2cb4d2ec4f1205a6c160981533827dbf74 100644 (file)
@@ -2086,6 +2086,15 @@ static int h2_wake(struct connection *conn)
 {
        struct h2c *h2c = conn->mux_ctx;
 
+       /*
+        * If we received early data, try to wake any stream, just in case
+        * at least one of them was waiting for the handshake
+        */
+       if ((conn->flags & (CO_FL_EARLY_SSL_HS | CO_FL_EARLY_DATA | CO_FL_HANDSHAKE)) ==
+           CO_FL_EARLY_DATA) {
+               h2_wake_some_streams(h2c, 0, 0);
+               conn->flags &= ~CO_FL_EARLY_DATA;
+       }
        if (conn->flags & CO_FL_ERROR || conn_xprt_read0_pending(conn) ||
            h2c->st0 == H2_CS_ERROR2 || h2c->flags & H2_CF_GOAWAY_FAILED ||
            (eb_is_empty(&h2c->streams_by_id) && h2c->last_sid >= 0 &&
index cd3a28b42a10245217fce9d2356cd52c144054d6..71bb477756a99127821846f93481edb346fd6b34 100644 (file)
@@ -51,6 +51,12 @@ static int mux_pt_wake(struct connection *conn)
 
        ret = cs->data_cb->wake ? cs->data_cb->wake(cs) : 0;
 
+       /* If we had early data, and we're done with the handshake
+        * then whe know the data are safe, and we can remove the flag.
+        */
+       if ((conn->flags & (CO_FL_EARLY_DATA | CO_FL_EARLY_SSL_HS | CO_FL_HANDSHAKE)) ==
+           CO_FL_EARLY_DATA)
+               conn->flags &= ~CO_FL_EARLY_DATA;
        if (ret >= 0)
                cs_update_mux_polling(cs);
        return ret;
index c2e3fffd4864a6a4aeef05ee0d3e76edca030733..6f9f27b98f4c2c3a9d711ff82df20db8424df767 100644 (file)
@@ -585,7 +585,6 @@ static int si_cs_wake_cb(struct conn_stream *cs)
         * the handshake.
         */
        if ((conn->flags & (CO_FL_EARLY_DATA | CO_FL_EARLY_SSL_HS)) == CO_FL_EARLY_DATA) {
-               conn->flags &= ~CO_FL_EARLY_DATA;
                task_wakeup(si_task(si), TASK_WOKEN_MSG);
        }