]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h2: make use of CS_FL_REOS to indicate that end of stream was seen
authorWilly Tarreau <w@1wt.eu>
Fri, 2 Mar 2018 11:26:37 +0000 (12:26 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 20 Jul 2018 17:35:14 +0000 (19:35 +0200)
This allows h2_rcv_buf() not to depend anymore on h2s at all and to become
generic.

src/mux_h2.c

index 7d55714cdb22339e8125367376e2012b55bd255f..22bdee958c1e4f26cfdd3fc04af0a6fdd2225e0e 100644 (file)
@@ -1606,6 +1606,8 @@ static struct h2s *h2c_frt_handle_headers(struct h2c *h2c, struct h2s *h2s)
        if (h2c->dff & H2_F_HEADERS_END_STREAM) {
                h2s->st = H2_SS_HREM;
                h2s->flags |= H2_SF_ES_RCVD;
+               /* note: cs cannot be null for now (just created above) */
+               h2s->cs->flags |= CS_FL_REOS;
        }
 
        if (!h2_frt_decode_headers(h2s))
@@ -1701,6 +1703,7 @@ static int h2c_frt_handle_data(struct h2c *h2c, struct h2s *h2s)
        if (h2c->dff & H2_F_DATA_END_STREAM) {
                h2s->st = H2_SS_HREM;
                h2s->flags |= H2_SF_ES_RCVD;
+               h2s->cs->flags |= CS_FL_REOS;
        }
 
        return 1;
@@ -2795,8 +2798,10 @@ static int h2_frt_decode_headers(struct h2s *h2s)
        h2c->st0 = H2_CS_FRAME_H;
        b_add(csbuf, outlen);
 
-       if (h2c->dff & H2_F_HEADERS_END_STREAM)
+       if (h2c->dff & H2_F_HEADERS_END_STREAM) {
                h2s->flags |= H2_SF_ES_RCVD;
+               h2s->cs->flags |= CS_FL_REOS;
+       }
 
  leave:
        free_trash_chunk(copy);
@@ -2960,8 +2965,10 @@ static int h2_frt_transfer_data(struct h2s *h2s)
        h2c->dpl = 0;
        h2c->st0 = H2_CS_FRAME_A; // send the corresponding window update
 
-       if (h2c->dff & H2_F_DATA_END_STREAM)
+       if (h2c->dff & H2_F_DATA_END_STREAM) {
                h2s->flags |= H2_SF_ES_RCVD;
+               h2s->cs->flags |= CS_FL_REOS;
+       }
 
        return flen + chklen;
  fail:
@@ -2975,7 +2982,6 @@ static int h2_frt_transfer_data(struct h2s *h2s)
  */
 static size_t h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
 {
-       struct h2s *h2s = cs->ctx;
        struct buffer *csbuf = &cs->rxbuf;
        size_t ret;
 
@@ -2986,7 +2992,7 @@ static size_t h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t coun
                cs->flags |= CS_FL_RCV_MORE;
        else {
                cs->flags &= ~CS_FL_RCV_MORE;
-               if (h2s->flags & H2_SF_ES_RCVD)
+               if (cs->flags & CS_FL_REOS)
                        cs->flags |= CS_FL_EOS;
        }