From bbe9522242a92b2d939a040ea2da3a4be7e9640a Mon Sep 17 00:00:00 2001 From: ruti <> Date: Tue, 22 Oct 2024 11:45:54 +0300 Subject: [PATCH] Call the post desync func only once #212 --- extend.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/extend.c b/extend.c index 67aa459..37f8f70 100644 --- a/extend.c +++ b/extend.c @@ -212,7 +212,7 @@ static bool check_proto_tcp(int proto, char *buffer, ssize_t n) } -static bool check_round(int nr[2], int r) +static bool check_round(int *nr, int r) { return (!nr[1] && r <= 1) || (r >= nr[0] && r <= nr[1]); } @@ -505,11 +505,14 @@ ssize_t tcp_recv_hook(struct poolhd *pool, struct eval *val, val->round_count++; val->pair->round_sent = 0; } - if (val->flag == FLAG_CONN - && check_round( - params.dp[val->pair->attempt].rounds, val->round_count) - && cancel_setup(val)) { - return -1; + if (val->flag == FLAG_CONN && !val->round_sent) { + int *nr = params.dp[val->pair->attempt].rounds; + + if (check_round(nr, val->round_count) + && !check_round(nr, val->round_count + 1) + && cancel_setup(val)) { + return -1; + } } return n; }