MINOR: spoe: Don't close connection in sync mode on processing timeout
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 10 Nov 2020 13:31:39 +0000 (14:31 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 13 Nov 2020 15:52:44 +0000 (16:52 +0100)
In sync mode, if an applet receives a ack while the processing delay has already
expired, there is not frame waiting for this ack. But there is no reason to
close the connection in this case. The ack may be ignored and the connection may
be reused to process another frame. The only reason to trigger an error and
close the connection is when the wrong ack is received while there is still a
frame waiting for its ack. In sync mode, this should never happen.

This patch may be backported in all versions supporting the SPOE.

(cherry picked from commit c7ba91039a7b0703971efd791ca2ca609afedb96)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit d9eb3c3de3211478b512ee7f8e548bb78211adf5)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 3217a352a6d99b3b23b2f552aa7505a64389ac1e)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/flt_spoe.c

index 3b3bc16..0109a32 100644 (file)
@@ -1042,8 +1042,17 @@ spoe_handle_agentack_frame(struct appctx *appctx, struct spoe_context **ctx,
                    (unsigned int)stream_id, (unsigned int)frame_id);
 
        SPOE_APPCTX(appctx)->status_code = SPOE_FRM_ERR_FRAMEID_NOTFOUND;
-       if (appctx->st0 == SPOE_APPCTX_ST_WAITING_SYNC_ACK)
-               return -1;
+       if (appctx->st0 == SPOE_APPCTX_ST_WAITING_SYNC_ACK) {
+               /* Report an error if we are waiting the ack for another frame,
+                * but not if there is no longer frame waiting for a ack
+                * (timeout)
+                */
+               if (!LIST_ISEMPTY(&SPOE_APPCTX(appctx)->waiting_queue) ||
+                   SPOE_APPCTX(appctx)->frag_ctx.ctx)
+                       return -1;
+               appctx->st0 = SPOE_APPCTX_ST_PROCESSING;
+               SPOE_APPCTX(appctx)->cur_fpa = 0;
+       }
        return 0;
 
   found: