BUG/MINOR: stream: Properly handle TCP>H1>H2 upgrades in http_wait_for_request

When a TCP stream is first upgraded to H1 and then to H2, we must be sure to
inhibit any connect and to properly handle the TCP stream destruction.

When the TCP stream is upgraded to H1, the HTTP analysers are set. Thus
http_wait_for_request() is called. In this case, the server connection must
be blocked, waiting for the request analysis. Otherwise, a server may be
assigned to the stream too early. It is especially a problem if the stream
is finally destroyed because of an implicit upgrade to H2.

In this case, the stream processing must be properly aborted to not have a
stalled stream. Thus, if a shutdown is detected in http_wait_for_request()
when an HTTP upgrade is performed, the stream is aborted.

It is a 2.4-specific bug. No backport is needed.
This commit is contained in:
Christopher Faulet 2021-03-15 17:10:12 +01:00
parent 57e4a1bf44
commit 97b3a61449

View File

@ -101,6 +101,22 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
*/
BUG_ON(!(s->flags & SF_IGNORE) || !c_empty(&s->req));
/* Don't connect for now */
channel_dont_connect(req);
/* A SHUTR at this stage means we are performing a "destructive"
* HTTP upgrade (TCP>H2). In this case, we can leave.
*/
if (req->flags & CF_SHUTR) {
s->logs.logwait = 0;
s->logs.level = 0;
channel_abort(&s->req);
channel_abort(&s->res);
req->analysers &= AN_REQ_FLT_END;
req->analyse_exp = TICK_ETERNITY;
DBG_TRACE_LEAVE(STRM_EV_STRM_ANA, s);
return 1;
}
DBG_TRACE_LEAVE(STRM_EV_STRM_ANA, s);
return 0;
}