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
This commit is contained in:
Christopher Faulet 2018-02-01 08:45:22 +01:00 committed by Willy Tarreau
parent f643b80429
commit d5216d474d

View 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);