MINOR: mux-h1: Try to wake up data layer first before calling its wake callback

Instead of calling the data layer wake callback function, we now first try
to wake it up. If the data layer is subscribed for receives or for sends,
its tasklet is woken up. The wake callback function is only called as the
last chance to notify the data layer.
This commit is contained in:
Christopher Faulet 2021-01-21 17:49:01 +01:00
parent 89e34c261b
commit ad4daf629e

View File

@ -2084,6 +2084,23 @@ static void h1_wake_stream_for_send(struct h1s *h1s)
} }
} }
/* alerts the data layer following this sequence :
* - if the h1s' data layer is subscribed to recv, then it's woken up for recv
* - if its subscribed to send, then it's woken up for send
* - if it was subscribed to neither, its ->wake() callback is called
*/
static void h1_alert(struct h1s *h1s)
{
if (h1s->subs) {
h1_wake_stream_for_recv(h1s);
h1_wake_stream_for_send(h1s);
}
else if (h1s->cs && h1s->cs->data_cb->wake != NULL) {
TRACE_POINT(H1_EV_STRM_WAKE, h1s->h1c->conn, h1s);
h1s->cs->data_cb->wake(h1s->cs);
}
}
/* Try to send an HTTP error with h1c->errcode status code. It returns 1 on success /* Try to send an HTTP error with h1c->errcode status code. It returns 1 on success
* and 0 on error. The flag H1C_F_ERR_PENDING is set on the H1 connection for * and 0 on error. The flag H1C_F_ERR_PENDING is set on the H1 connection for
* retryable errors (allocation error or buffer full). On success, the error is * retryable errors (allocation error or buffer full). On success, the error is
@ -2491,10 +2508,7 @@ static int h1_process(struct h1c * h1c)
if ((h1c->flags & H1C_F_ST_ERROR) || (conn->flags & CO_FL_ERROR)) if ((h1c->flags & H1C_F_ST_ERROR) || (conn->flags & CO_FL_ERROR))
h1s->cs->flags |= CS_FL_ERROR; h1s->cs->flags |= CS_FL_ERROR;
TRACE_POINT(H1_EV_STRM_WAKE, h1c->conn, h1s); TRACE_POINT(H1_EV_STRM_WAKE, h1c->conn, h1s);
if (h1s->cs->data_cb->wake) { h1_alert(h1s);
TRACE_POINT(H1_EV_STRM_WAKE, h1c->conn, h1s);
h1s->cs->data_cb->wake(h1s->cs);
}
} }
} }
@ -2590,10 +2604,8 @@ static int h1_wake(struct connection *conn)
if (ret == 0) { if (ret == 0) {
struct h1s *h1s = h1c->h1s; struct h1s *h1s = h1c->h1s;
if ((h1c->flags & H1C_F_ST_ATTACHED) && h1s->cs->data_cb->wake) { if (h1c->flags & H1C_F_ST_ATTACHED)
TRACE_POINT(H1_EV_STRM_WAKE, h1c->conn, h1s); h1_alert(h1s);
ret = h1s->cs->data_cb->wake(h1s->cs);
}
} }
return ret; return ret;
} }