BUG/MEDIUM: http-ana: Try to handle response before handling server abort

In the request analyser responsible to forward the request, we try to detect
the server abort to stop the request forwarding. However, we must be careful
to not block the response processing, if any. Indeed, it is possible to get
the response and the server abort in same time. In this case, we must try to
forward the response to the client first.

So to fix the issue, in the request analyser we no longer handle the server
abort if the response channel is not empty. In the end, the response
analyser is able to detect the server abort if it is relevant. Otherwise,
the stream will be woken up after the response forwarding and the server
abort should be handled at this stage.

This patch should be backported as far as 2.7 only because the risk of
breakage is high. And it is probably a good idea to wait a bit before
backporting it.
This commit is contained in:
Christopher Faulet 2023-09-14 11:12:32 +02:00
parent cbbee15462
commit d3e379b3ce

View File

@ -985,8 +985,12 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
if ((s->scb->flags & SC_FL_SHUT_DONE) && co_data(req)) {
/* request errors are most likely due to the server aborting the
* transfer. */
goto return_srv_abort;
* transfer.Bit handle server aborts only if there is no
* response. Otherwise, let a change to foward the response
* first.
*/
if (htx_is_empty(htxbuf(&s->res.buf)))
goto return_srv_abort;
}
http_end_request(s);
@ -1023,8 +1027,13 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
waiting:
/* waiting for the last bits to leave the buffer */
if (s->scb->flags & SC_FL_SHUT_DONE)
goto return_srv_abort;
if (s->scb->flags & SC_FL_SHUT_DONE) {
/* Handle server aborts only if there is no response. Otherwise,
* let a change to foward the response first.
*/
if (htx_is_empty(htxbuf(&s->res.buf)))
goto return_srv_abort;
}
/* When TE: chunked is used, we need to get there again to parse remaining
* chunks even if the client has closed, so we don't want to set CF_DONTCLOSE.