From 5f5c94617e33382621d43c3ccf0af7049c80d9c6 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 30 Mar 2023 15:48:27 +0200 Subject: [PATCH] BUG/MEDIUM: channel: Improve reports for shut in co_getblk() 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/channel.c b/src/channel.c index 62fff1b..68360d9 100644 --- a/src/channel.c +++ b/src/channel.c @@ -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; -- 1.7.10.4