From fc10f599cc5e5606c15be4828848e04ed2c70f9c Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 30 Jan 2019 19:28:32 +0100 Subject: [PATCH] BUG/MEDIUM: mux-h2: fix two half-closed to closed transitions When receiving a HEADERS or DATA frame with END_STREAM set, we would inconditionally switch to half-closed(remote). This is wrong because we could already have been in half-closed(local) and need to switch to closed. This happens in the following situations : - receipt of the end of a client upload after we've already responded (e.g. redirects to POST requests) - receipt of a response on the backend side after we've already finished sending the request (most common case). This may possibly have caused some streams to stay longer than needed at the end of a transfer, though this is not apparent in tests. This must be backported to 1.9 and 1.8. --- src/mux_h2.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mux_h2.c b/src/mux_h2.c index 49e2068..35bdd17 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -1980,7 +1980,10 @@ static struct h2s *h2c_frt_handle_headers(struct h2c *h2c, struct h2s *h2s) h2s->flags |= H2_SF_ES_RCVD; if (h2s->flags & H2_SF_ES_RCVD) { - h2s->st = H2_SS_HREM; + if (h2s->st == H2_SS_OPEN) + h2s->st = H2_SS_HREM; + else + h2s_close(h2s); h2s->cs->flags |= CS_FL_REOS; } @@ -2129,7 +2132,11 @@ static int h2c_frt_handle_data(struct h2c *h2c, struct h2s *h2s) /* last frame */ if (h2c->dff & H2_F_DATA_END_STREAM) { - h2s->st = H2_SS_HREM; + if (h2s->st == H2_SS_OPEN) + h2s->st = H2_SS_HREM; + else + h2s_close(h2s); + h2s->flags |= H2_SF_ES_RCVD; h2s->cs->flags |= CS_FL_REOS; -- 1.7.10.4