MINOR: mux-h2: make h2_wake_some_streams() not depend on the CS flags
It's problematic to have to pass some CS flags to this function because
that forces some h2s state transistions to update them just in time
while some of them are supposed to only be updated during I/O operations.
As a first step this patch transfers the decision to pass CS_FL_ERR_PENDING
from the caller to the leaf function h2s_wake_one_stream(). It is easy
since this is the only flag passed there and it depends on the position of
the stream relative to the last_sid if it was set.
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 40ff11a..27d58e7 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -1432,6 +1432,9 @@
return;
}
+ if (h2s->h2c->last_sid > 0 && (!h2s->id || h2s->id > h2s->h2c->last_sid))
+ flags |= CS_FL_ERR_PENDING;
+
h2s->cs->flags |= flags;
if ((flags & CS_FL_ERR_PENDING) && (h2s->cs->flags & CS_FL_EOS))
h2s->cs->flags |= CS_FL_ERROR;
@@ -1449,10 +1452,11 @@
/* wake the streams attached to the connection, whose id is greater than <last>
* or unassigned.
*/
-static void h2_wake_some_streams(struct h2c *h2c, int last, uint32_t flags)
+static void h2_wake_some_streams(struct h2c *h2c, int last)
{
struct eb32_node *node;
struct h2s *h2s;
+ uint32_t flags = 0;
if (h2c->st0 >= H2_CS_ERROR || h2c->conn->flags & CO_FL_ERROR)
flags |= CS_FL_ERR_PENDING;
@@ -1851,9 +1855,9 @@
last = h2_get_n32(&h2c->dbuf, 0);
h2c->errcode = h2_get_n32(&h2c->dbuf, 4);
- h2_wake_some_streams(h2c, last, CS_FL_ERR_PENDING);
if (h2c->last_sid < 0)
h2c->last_sid = last;
+ h2_wake_some_streams(h2c, last);
return 1;
}
@@ -2882,7 +2886,7 @@
h2c->st0 == H2_CS_ERROR2 || h2c->flags & H2_CF_GOAWAY_FAILED ||
(eb_is_empty(&h2c->streams_by_id) && h2c->last_sid >= 0 &&
h2c->max_id >= h2c->last_sid)) {
- h2_wake_some_streams(h2c, 0, 0);
+ h2_wake_some_streams(h2c, 0);
if (eb_is_empty(&h2c->streams_by_id)) {
/* no more stream, kill the connection now */
@@ -2946,7 +2950,7 @@
h2c->task = NULL;
h2c_error(h2c, H2_ERR_NO_ERROR);
- h2_wake_some_streams(h2c, 0, 0);
+ h2_wake_some_streams(h2c, 0);
if (b_data(&h2c->mbuf)) {
/* don't even try to send a GOAWAY, the buffer is stuck */