]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: spoe: Always try to receive or send the frame to detect shutdowns
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 1 Feb 2018 07:45:22 +0000 (08:45 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 2 Feb 2018 15:00:31 +0000 (16:00 +0100)
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

src/flt_spoe.c

index cb97164677cbaa85a7a43353caa07e12707550fe..5b6e25370b08c47752db0daf6967af53ff8d0038 100644 (file)
@@ -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 <buf> 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);