]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: connection: Add a new CS_FL_ERR_PENDING flag to conn_streams.
authorOlivier Houchard <ohouchard@haproxy.com>
Mon, 17 Dec 2018 13:16:46 +0000 (14:16 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 17 Dec 2018 20:54:14 +0000 (21:54 +0100)
Add a new flag to conn_streams, CS_FL_ERR_PENDING. This is to be set instead
of CS_FL_ERR in case there's still more data to be read, so that we read all
the data before closing.

include/types/connection.h
src/mux_h2.c

index d1819cc2c23b0b125c29049bde1f6c2408676e0f..3b7f4e1bbaa4dd718e08705912fa5b586f8aa1b5 100644 (file)
@@ -81,6 +81,7 @@ enum {
        CS_FL_ERROR         = 0x00000100,  /* a fatal error was reported */
        CS_FL_RCV_MORE      = 0x00000200,  /* We may have more bytes to transfert */
        CS_FL_WANT_ROOM     = 0x00000400,  /* More bytes to transfert, but not enough room */
+       CS_FL_ERR_PENDING   = 0x00000800,  /* An error is pending, but there's still data to be read */
        CS_FL_EOS           = 0x00001000,  /* End of stream delivered to data layer */
        CS_FL_REOS          = 0x00002000,  /* End of stream received (buffer not empty) */
        CS_FL_WAIT_FOR_HS   = 0x00010000,  /* This stream is waiting for handhskae */
index dc28b12d065b1900526d9e522aaa3f77de046212..6c160d02cb0bf5684706179e64a9a8e7d5a6dfbb 100644 (file)
@@ -1739,7 +1739,7 @@ static int h2c_handle_rst_stream(struct h2c *h2c, struct h2s *h2s)
        h2s_close(h2s);
 
        if (h2s->cs) {
-               h2s->cs->flags |= CS_FL_REOS | CS_FL_ERROR;
+               h2s->cs->flags |= CS_FL_REOS | CS_FL_ERR_PENDING;
                if (h2s->recv_wait) {
                        struct wait_event *sw = h2s->recv_wait;
 
@@ -4595,6 +4595,8 @@ static size_t h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t coun
                if (htx_is_empty(h2s_htx)) {
                        if (cs->flags & CS_FL_REOS)
                                cs->flags |= CS_FL_EOS;
+                       if (cs->flags & CS_FL_ERR_PENDING)
+                               cs->flags |= CS_FL_ERROR;
                        goto end;
                }
 
@@ -4618,6 +4620,8 @@ static size_t h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t coun
                cs->flags &= ~(CS_FL_RCV_MORE | CS_FL_WANT_ROOM);
                if (cs->flags & CS_FL_REOS)
                        cs->flags |= CS_FL_EOS;
+               if (cs->flags & CS_FL_ERR_PENDING)
+                       cs->flags |= CS_FL_ERROR;
                if (b_size(&h2s->rxbuf)) {
                        b_free(&h2s->rxbuf);
                        offer_buffers(NULL, tasks_run_queue);