From: Christopher Faulet Date: Thu, 1 Feb 2018 07:45:22 +0000 (+0100) Subject: BUG/MEDIUM: spoe: Always try to receive or send the frame to detect shutdowns X-Git-Tag: v1.9-dev1~464 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5216d474d69856a282e4443f180af2093a80d6c;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: spoe: Always try to receive or send the frame to detect shutdowns Before, we checked if the buffer was allocated or not to avoid sending or receiving a frame. This was done to not call ci_putblk or co_getblk if there is nothing to do. But the checks on the buffers are also done in these functions. So this is not mandatory here. But in these functions, the channel state is also checked, so an error is returned if it is closed. By skipping the call, we also skip the checks on the channel state, delaying shutdowns detection. Now, we always try to send or receive a frame. So if the corresponding channel is closed, we can immediatly handle the error. This patch must be backported in 1.8 --- diff --git a/src/flt_spoe.c b/src/flt_spoe.c index cb97164677..5b6e25370b 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -1136,17 +1136,13 @@ spoe_send_frame(struct appctx *appctx, char *buf, size_t framesz) int ret; uint32_t netint; - if (si_ic(si)->buf == &buf_empty) - goto retry; - /* 4 bytes are reserved at the beginning of to store the frame * length. */ netint = htonl(framesz); memcpy(buf, (char *)&netint, 4); ret = ci_putblk(si_ic(si), buf, framesz+4); - if (ret <= 0) { - if (ret == -1) { + if ((ret == -3 && si_ic(si)->buf == &buf_empty) || ret == -1) { retry: si_applet_cant_put(si); return 1; /* retry */ @@ -1167,9 +1163,6 @@ spoe_recv_frame(struct appctx *appctx, char *buf, size_t framesz) int ret; uint32_t netint; - if (si_oc(si)->buf == &buf_empty) - goto retry; - ret = co_getblk(si_oc(si), (char *)&netint, 4, 0); if (ret > 0) { framesz = ntohl(netint);