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.

(cherry picked from commit 39066c27384653b41b95370fc4dec4469a637a23)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
diff --git a/src/tcpcheck.c b/src/tcpcheck.c
index 75d97f3..964dcf8 100644
--- a/src/tcpcheck.c
+++ b/src/tcpcheck.c
@@ -1222,6 +1222,10 @@
 	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 @@
 		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 @@
 	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 @@
 		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;