From: Christopher Faulet Date: Thu, 16 Jul 2020 09:43:46 +0000 (+0200) Subject: BUG/MEDIUM: channel: Be aware of SHUTW_NOW flag when output data are peeked X-Git-Tag: v2.3-dev1~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f706a794d8b8d854cba4414adb6f9a1297c6fd02;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: channel: Be aware of SHUTW_NOW flag when output data are peeked The CF_SHUTW_NOW flag must be handled the same way than the CF_SHUTW flag in co_getblk_nc() and co_getline_nc() functions. It is especally important when we try to peek a line from outgoing data. In this case, an unfinished line is blocked an nothing is peeked if the CF_SHUTW_NOW flag is set. But the blocked data pevent the transition to CF_SHUTW. The above functions are only used by LUA cosockets. Because of this bug, we may experienced wakeups in loop of the cosocket's io handler if we try to read a line on a closed socket with a pending unfinished line (no LF found at the end). This patch should fix issue #744. It must be backported to all supported versions. --- diff --git a/src/channel.c b/src/channel.c index a3b7b9e3ea..a139eada12 100644 --- a/src/channel.c +++ b/src/channel.c @@ -259,7 +259,7 @@ int co_getblk(const struct channel *chn, char *blk, int len, int offset) int co_getblk_nc(const struct channel *chn, const char **blk1, size_t *len1, const char **blk2, size_t *len2) { if (unlikely(co_data(chn) == 0)) { - if (chn->flags & CF_SHUTW) + if (chn->flags & (CF_SHUTW|CF_SHUTW_NOW)) return -1; return 0; } @@ -301,7 +301,7 @@ int co_getline_nc(const struct channel *chn, } } - if (chn->flags & CF_SHUTW) { + if (chn->flags & (CF_SHUTW|CF_SHUTW_NOW)) { /* If we have found no LF and the buffer is shut, then * the resulting string is made of the concatenation of * the pending blocks (1 or 2).