From: Christopher Faulet Date: Wed, 25 Nov 2020 12:34:51 +0000 (+0100) Subject: MINOR: tcpcheck: Don't handle anymore in-progress send rules in tcpcheck_main X-Git-Tag: v2.4-dev2~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=39066c27384653b41b95370fc4dec4469a637a23;p=thirdparty%2Fhaproxy.git MINOR: tcpcheck: Don't handle anymore in-progress send rules in tcpcheck_main The special handling of in-progress send rules at the begining of tcpcheck_main() function can be removed. Instead, at the begining of the tcpcheck_eval_send() function, we test is there is some data in the output buffer. In this case, it means we are evaluating an unfinished send rule and we can jump to the sending part, skipping the formatting part. This patch is mandatory for a major fix on the checks and must be backported as far as 2.2. --- diff --git a/src/tcpcheck.c b/src/tcpcheck.c index 3ecb0ba543..e87b9f3da1 100644 --- a/src/tcpcheck.c +++ b/src/tcpcheck.c @@ -1222,6 +1222,10 @@ enum tcpcheck_eval_ret tcpcheck_eval_send(struct check *check, struct tcpcheck_r struct buffer *tmp = NULL; struct htx *htx = NULL; + /* Data already pending in the output buffer, send them now */ + if (b_data(&check->bo)) + goto do_send; + /* reset the read & write buffer */ b_reset(&check->bi); b_reset(&check->bo); @@ -1352,7 +1356,7 @@ enum tcpcheck_eval_ret tcpcheck_eval_send(struct check *check, struct tcpcheck_r goto out; }; - + do_send: if (conn->mux->snd_buf(cs, &check->bo, (IS_HTX_CONN(conn) ? (htxbuf(&check->bo))->data: b_data(&check->bo)), 0) <= 0) { if ((conn->flags & CO_FL_ERROR) || (cs->flags & CS_FL_ERROR)) { @@ -1927,7 +1931,7 @@ int tcpcheck_main(struct check *check) struct conn_stream *cs = check->cs; struct connection *conn = cs_conn(cs); int must_read = 1, last_read = 0; - int ret, retcode = 0; + int retcode = 0; enum tcpcheck_eval_ret eval_ret; /* here, we know that the check is complete or that it failed */ @@ -1968,34 +1972,12 @@ int tcpcheck_main(struct check *check) rule = LIST_NEXT(&check->current_step->list, typeof(rule), list); } - /* 3- check for pending outgoing data. It only happens during - * TCPCHK_ACT_SEND. */ - else if (check->current_step && check->current_step->action == TCPCHK_ACT_SEND) { - if (b_data(&check->bo)) { - /* We're already waiting to be able to send, give up */ - if (check->wait_list.events & SUB_RETRY_SEND) - goto out; - - ret = conn->mux->snd_buf(cs, &check->bo, - (IS_HTX_CONN(conn) ? (htxbuf(&check->bo))->data: b_data(&check->bo)), 0); - if (ret <= 0) { - if ((conn->flags & CO_FL_ERROR) || (cs->flags & CS_FL_ERROR)) - goto out_end_tcpcheck; - } - if ((IS_HTX_CONN(conn) && !htx_is_empty(htxbuf(&check->bo))) || b_data(&check->bo)) { - conn->mux->subscribe(cs, SUB_RETRY_SEND, &check->wait_list); - goto out; - } - } - rule = LIST_NEXT(&check->current_step->list, typeof(rule), list); - } - - /* 4- check if a rule must be resume. It happens if check->current_step + /* 3- check if a rule must be resume. It happens if check->current_step * is defined. */ else if (check->current_step) rule = check->current_step; - /* 5- It is the first evaluation. We must create a session and preset + /* 4- It is the first evaluation. We must create a session and preset * tcp-check variables */ else { struct tcpcheck_var *var;