From d247be0620c35ea0a43074fd88c6a520629c1823 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Thu, 6 Dec 2018 16:22:29 +0100 Subject: [PATCH] BUG/MEDIUM: connections: Split CS_FL_RCV_MORE into 2 flags. CS_FL_RCV_MORE is used in two cases, to let the conn_stream know there may be more data available, and to let it know that it needs more room. We can't easily differentiate between the two, and that may leads to hangs, so split it into two flags, CS_FL_RCV_MORE, that means there may be more data, and CS_FL_WANT_ROOM, that means we need more room. This should not be backported. --- include/types/connection.h | 3 ++- src/mux_h1.c | 4 ++-- src/mux_h2.c | 4 ++-- src/stream_interface.c | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/types/connection.h b/include/types/connection.h index 8a12cec1d..27c839f81 100644 --- a/include/types/connection.h +++ b/include/types/connection.h @@ -78,7 +78,8 @@ enum { CS_FL_ERROR = 0x00000100, /* a fatal error was reported */ - CS_FL_RCV_MORE = 0x00000200, /* more bytes to receive but not enough room */ + 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_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 */ diff --git a/src/mux_h1.c b/src/mux_h1.c index 3b845a6ec..e1552346c 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -1269,13 +1269,13 @@ static size_t h1_process_input(struct h1c *h1c, struct buffer *buf, int flags) if (b_data(&h1c->ibuf)) { if (!htx_is_empty(htx)) - h1s->cs->flags |= CS_FL_RCV_MORE; + h1s->cs->flags |= CS_FL_RCV_MORE | CS_FL_WANT_ROOM; } else { h1_release_buf(h1c, &h1c->ibuf); h1_sync_messages(h1c); - h1s->cs->flags &= ~CS_FL_RCV_MORE; + h1s->cs->flags &= ~(CS_FL_RCV_MORE | CS_FL_WANT_ROOM); if (h1s->cs->flags & CS_FL_REOS) h1s->cs->flags |= CS_FL_EOS; } diff --git a/src/mux_h2.c b/src/mux_h2.c index 06ee7d798..dd321ece0 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -4527,9 +4527,9 @@ static size_t h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t coun } if (b_data(&h2s->rxbuf)) - cs->flags |= CS_FL_RCV_MORE; + cs->flags |= (CS_FL_RCV_MORE | CS_FL_WANT_ROOM); else { - cs->flags &= ~CS_FL_RCV_MORE; + cs->flags &= ~(CS_FL_RCV_MORE | CS_FL_WANT_ROOM); if (cs->flags & CS_FL_REOS) cs->flags |= CS_FL_EOS; if (b_size(&h2s->rxbuf)) { diff --git a/src/stream_interface.c b/src/stream_interface.c index 73d9d4f8e..b4efe0c42 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -1215,7 +1215,7 @@ int si_cs_recv(struct conn_stream *cs) (co_data(ic) ? CO_RFL_BUF_WET : 0) | ((channel_recv_limit(ic) < b_size(&ic->buf)) ? CO_RFL_KEEP_RSV : 0)); - if (b_data(&ic->buf) && (cs->flags & CS_FL_RCV_MORE)) + if (cs->flags & CS_FL_WANT_ROOM) si_rx_room_blk(si); if (cs->flags & CS_FL_READ_PARTIAL) {