MINOR: early data: Don't rely on CO_FL_EARLY_DATA to wake up streams.

Instead of looking for CO_FL_EARLY_DATA to know if we have to try to wake
up a stream, because it is waiting for a SSL handshake, instead add a new
conn_stream flag, CS_FL_WAIT_FOR_HS. This way we don't have to rely on
CO_FL_EARLY_DATA, and we will only wake streams that are actually waiting.
diff --git a/include/types/connection.h b/include/types/connection.h
index 4bcac60..cea61f5 100644
--- a/include/types/connection.h
+++ b/include/types/connection.h
@@ -70,6 +70,7 @@
 	CS_FL_ERROR         = 0x00000100,  /* a fatal error was reported */
 	CS_FL_RCV_MORE      = 0x00000200,  /* more bytes to receive but not enough room */
 	CS_FL_EOS           = 0x00001000,  /* End of stream */
+	CS_FL_WAIT_FOR_HS   = 0x00010000,  /* This stream is waiting for handhskae */
 };
 
 /* cs_shutr() modes */
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 7bb51ea..6c63b86 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -59,6 +59,7 @@
 /* other flags */
 #define H2_CF_GOAWAY_SENT       0x00000100  // a GOAWAY frame was successfully sent
 #define H2_CF_GOAWAY_FAILED     0x00000200  // a GOAWAY frame failed to be sent
+#define H2_CF_WAIT_FOR_HS       0x00000400  // We did check that at least a stream was waiting for handshake
 
 
 /* H2 connection state, in h2c->st0 */
@@ -2275,14 +2276,25 @@
 	}
 
 	/*
-	 * If we received early data, try to wake any stream, just in case
-	 * at least one of them was waiting for the handshake
+	 * If we received early data, and the handshake is done, wake
+	 * any stream that was waiting for it.
 	 */
-	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 (!(h2c->flags & H2_CF_WAIT_FOR_HS) &&
+	    (conn->flags & (CO_FL_EARLY_SSL_HS | CO_FL_HANDSHAKE | CO_FL_EARLY_DATA)) == CO_FL_EARLY_DATA) {
+		struct eb32_node *node;
+		struct h2s *h2s;
+
+		h2c->flags |= H2_CF_WAIT_FOR_HS;
+		node = eb32_lookup_ge(&h2c->streams_by_id, 1);
+
+		while (node) {
+			h2s = container_of(node, struct h2s, by_id);
+			if (h2s->cs->flags & CS_FL_WAIT_FOR_HS)
+				h2s->cs->data_cb->wake(h2s->cs);
+			node = eb32_next(node);
+		}
 	}
+
 	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 &&
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index c2fa45f..76f8425 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -8711,11 +8711,14 @@
                                        struct session *sess, struct stream *s, int flags)
 {
 	struct connection *conn;
+	struct conn_stream *cs;
 
 	conn = objt_conn(sess->origin);
+	cs = objt_cs(s->si[0].end);
 
-	if (conn) {
+	if (conn && cs) {
 		if (conn->flags & (CO_FL_EARLY_SSL_HS | CO_FL_SSL_WAIT_HS)) {
+			cs->flags |= CS_FL_WAIT_FOR_HS;
 			s->req.flags |= CF_READ_NULL;
 			return ACT_RET_YIELD;
 		}
diff --git a/src/stream_interface.c b/src/stream_interface.c
index 9f61a75..a78694f 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -584,7 +584,9 @@
 	 * in the event there's an analyser waiting for the end of
 	 * the handshake.
 	 */
-	if ((conn->flags & (CO_FL_EARLY_DATA | CO_FL_EARLY_SSL_HS)) == CO_FL_EARLY_DATA) {
+	if (!(conn->flags & (CO_FL_HANDSHAKE | CO_FL_EARLY_SSL_HS)) &&
+	    (cs->flags & CS_FL_WAIT_FOR_HS)) {
+		cs->flags &= ~CS_FL_WAIT_FOR_HS;
 		task_wakeup(si_task(si), TASK_WOKEN_MSG);
 	}