]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: h2: When sending in HTX, make sure the caller knows we sent all.
authorOlivier Houchard <ohouchard@haproxy.com>
Mon, 3 Dec 2018 18:13:29 +0000 (19:13 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 4 Dec 2018 17:32:39 +0000 (18:32 +0100)
In h2_snd_buf(), when running with htx, make sure we return the amount of
data the caller specified, if we emptied the buffer, as it is what the
caller expects, and will lead to him properly consider the buffer to be
empty.

src/mux_h2.c

index 8d5c9de073788af7fa5a0cff207188c36912f99a..b93aa24f3e54189a257bdb154e0b0e9e6bd856e7 100644 (file)
@@ -4559,6 +4559,7 @@ static void h2_stop_senders(struct h2c *h2c)
 static size_t h2_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags)
 {
        struct h2s *h2s = cs->ctx;
+       size_t orig_count = count;
        size_t total = 0;
        size_t ret;
        struct htx *htx;
@@ -4722,6 +4723,14 @@ static size_t h2_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t coun
            (h2s->flags & H2_SF_BLK_MBUSY))
                h2_stop_senders(h2s->h2c);
 
+       /* If we're running HTX, and we read the whole buffer, then pretend
+        * we read exactly what the caller specified, as with HTX the caller
+        * will always give the buffer size, instead of the amount of data
+        * available.
+        */
+       if (htx && !b_data(buf))
+               total = orig_count;
+
        if (total > 0) {
                if (!(h2s->h2c->wait_event.wait_reason & SUB_CAN_SEND))
                        tasklet_wakeup(h2s->h2c->wait_event.task);