]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h1: Report EOI instead EOS on parsing error or H2 upgrade
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 17 May 2019 07:14:10 +0000 (09:14 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 24 May 2019 07:11:01 +0000 (09:11 +0200)
When a parsing error occurrs in the H1 multiplexer, we stop to copy HTX
blocks. So the error may be reported with an emtpy HTX message. For instance, if
the headers parsing failed. When it happens, the flag CS_FL_EOS is also set on
the conn_stream. But it is an error. Most of time, it is set on established
connections, so it is not really an issue. But if it happens when the server
connection is not fully established, the connection is shut down immediatly and
the stream-interface is switched from SI_ST_CON to SI_ST_DIS/CLO. So HTX
analyzers have no chance to catch the error.

Instead of setting CS_FL_EOS, it is fairly better to set CS_FL_EOI, which is the
right flag to use. The same is also done on H2 upgrade. As a side effet of this
fix, in the stream-interface code, we must now set the flag CF_READ_PARTIAL on
the channel when the flag CF_EOI is set. It is a warranty to wakeup the stream
when EOI is reported to the channel while no data are received.

This patch must be backported to 1.9.

src/mux_h1.c
src/stream_interface.c

index 111e26295391e9426141112c89f20a61b2397ad9..b8977d06cd7621cdd2a044b775392e078d31b5f2 100644 (file)
@@ -1073,7 +1073,7 @@ static size_t h1_process_headers(struct h1s *h1s, struct h1m *h1m, struct htx *h
 
   h2c_upgrade:
        h1s->h1c->flags |= H1C_F_UPG_H2C;
-       h1s->cs->flags |= CS_FL_REOS;
+       h1s->cs->flags |= CS_FL_EOI;
        htx->flags |= HTX_FL_UPGRADE;
        ret = 0;
        goto end;
@@ -1386,7 +1386,7 @@ static size_t h1_process_input(struct h1c *h1c, struct buffer *buf, int flags)
        b_reset(&h1c->ibuf);
        htx->flags |= HTX_FL_PARSING_ERROR;
        htx_to_buf(htx, buf);
-       h1s->cs->flags |= CS_FL_EOS;
+       h1s->cs->flags |= CS_FL_EOI;
        return 0;
 }
 
index 22391336e7e5c18044662d4120391eed357a5a9a..071a7653605ff72f6cf5791eab7f00f5c62fdf69 100644 (file)
@@ -597,7 +597,7 @@ static int si_cs_process(struct conn_stream *cs)
        /* Report EOI on the channel if it was reached from the mux point of
         * view. */
        if ((cs->flags & CS_FL_EOI) && !(ic->flags & CF_EOI))
-               ic->flags |= CF_EOI;
+               ic->flags |= (CF_EOI|CF_READ_PARTIAL);
 
        /* Second step : update the stream-int and channels, try to forward any
         * pending data, then possibly wake the stream up based on the new