From: Willy Tarreau Date: Tue, 6 Aug 2019 08:11:02 +0000 (+0200) Subject: BUG/MINOR: mux-h2: use CANCEL, not STREAM_CLOSED in h2c_frt_handle_data() X-Git-Tag: v2.1-dev2~232 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=082c45769b00d9da128ea75d72f7b9c35dede8be;p=thirdparty%2Fhaproxy.git BUG/MINOR: mux-h2: use CANCEL, not STREAM_CLOSED in h2c_frt_handle_data() There is a test on the existence of the conn_stream when receiving data, to be sure to have somewhere to deliver it. Right now it responds with STREAM_CLOSED, which is not correct since from an H2 point of view the stream is not closed and a peer could be upset to see this. After some analysis, it is important to keep this test to be sure not to fill the rxbuf then stall the connection. Another option could be to modiffy h2_frt_transfer_data() to silently discard any contents but the CANCEL error code is designed exactly for this and to save the peer from continuing to stream data that will be discarded, so better switch to using this. This must be backported as far as 1.8. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index f085e2b11c..06eb5f4e02 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -2182,7 +2182,11 @@ static int h2c_frt_handle_data(struct h2c *h2c, struct h2s *h2s) * notify the stream about any change. */ if (!h2s->cs) { - error = H2_ERR_STREAM_CLOSED; + /* The upper layer has already closed, this may happen on + * 4xx/redirects during POST, or when receiving a response + * from an H2 server after the client has aborted. + */ + error = H2_ERR_CANCEL; goto strm_err; }