]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: channel: Improve reports for shut in co_getblk()
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 30 Mar 2023 13:48:27 +0000 (15:48 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 5 Apr 2023 06:57:05 +0000 (08:57 +0200)
When co_getblk() is called with a length and an offset to 0, shutdown is
never reported. It may be an issue when the function is called to retrieve
all available output data, while there is no output data at all. And it
seems pretty annoying to handle this case in the caller.

Thus, now, in co_getblk(), -1 is returned when the channel is empty and a
shutdown was received.

There is no real reason to backport this patch alone. However, another fix
will rely on it.

src/channel.c

index 62fff1b0e093b531825a9eec36db8df5e989bc46..68360d99d28e17d280938c9e1b9c721164c039e7 100644 (file)
@@ -398,7 +398,7 @@ int co_getblk(const struct channel *chn, char *blk, int len, int offset)
        if (chn->flags & CF_SHUTW)
                return -1;
 
-       if (len + offset > co_data(chn)) {
+       if (len + offset > co_data(chn) || co_data(chn) == 0) {
                if (chn->flags & (CF_SHUTW|CF_SHUTW_NOW))
                        return -1;
                return 0;