MINOR: checks: Make resume conditions more explicit in tcpcheck_main()
First tests before executing the loop on tcp-check rules in tcpcheck_main()
function have been slightly modified to be more explicit and easier to
understand.
diff --git a/src/checks.c b/src/checks.c
index 4192720..7f2a859 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -3254,38 +3254,43 @@
/* 2- check if we are waiting for the connection establishment. It only
* happens during TCPCHK_ACT_CONNECT. */
- if (conn && (conn->flags & CO_FL_WAIT_XPRT))
- goto out;
-
- /* 3- check for pending outgoing data. It only happens during TCPCHK_ACT_SEND. */
- if (conn && b_data(&check->bo)) {
- ret = conn->mux->snd_buf(cs, &check->bo, b_data(&check->bo), 0);
- if (ret <= 0) {
- if ((conn && conn->flags & CO_FL_ERROR) || (cs && cs->flags & CS_FL_ERROR))
- goto out_end_tcpcheck;
+ if (check->current_step && check->current_step->action == TCPCHK_ACT_CONNECT) {
+ rule = LIST_NEXT(&check->current_step->list, typeof(rule), list);
+ if (conn && (conn->flags & CO_FL_WAIT_XPRT)) {
+ if (rule->action == TCPCHK_ACT_SEND)
+ conn->mux->subscribe(cs, SUB_RETRY_SEND, &check->wait_list);
+ else if (rule->action == TCPCHK_ACT_EXPECT)
+ conn->mux->subscribe(cs, SUB_RETRY_RECV, &check->wait_list);
goto out;
}
- if (b_data(&check->bo)) {
- cs->conn->mux->subscribe(cs, SUB_RETRY_SEND, &check->wait_list);
- goto out;
+ }
+
+ /* 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 (conn && b_data(&check->bo)) {
+ ret = conn->mux->snd_buf(cs, &check->bo, b_data(&check->bo), 0);
+ if (ret <= 0) {
+ if ((conn && conn->flags & CO_FL_ERROR) || (cs && cs->flags & CS_FL_ERROR))
+ goto out_end_tcpcheck;
+ goto out;
+ }
+ if (b_data(&check->bo)) {
+ cs->conn->mux->subscribe(cs, SUB_RETRY_SEND, &check->wait_list);
+ goto out;
+ }
}
+ rule = LIST_NEXT(&check->current_step->list, typeof(rule), list);
}
- /* Now evaluate the tcp-check rules */
+ /* 4- check if a rule must be resume. It happens if check->current_step
+ * is defined. */
+ else if (check->current_step)
+ rule = check->current_step;
- /* If check->current_step is defined, we are in resume condition. For
- * TCPCHK_ACT_CONNECT and TCPCHK_ACT_SEND rules, we must go to the next
- * rule before resuming the evaluation. For TCPCHK_ACT_EXPECT, we
- * re-evaluate the current rule. Others cannot yield.
- */
- if (check->current_step) {
- if (check->current_step->action == TCPCHK_ACT_CONNECT ||
- check->current_step->action == TCPCHK_ACT_SEND)
- rule = LIST_NEXT(&check->current_step->list, typeof(rule), list);
- else
- rule = check->current_step;
- }
- else {
+ /* 5- It is the first evaluation. We must create a session and preset
+ * tcp-check variables */
+ else {
struct tcpcheck_var *var;
/* First evaluation, create a session */
@@ -3309,6 +3314,8 @@
}
}
+ /* Now evaluate the tcp-check rules */
+
list_for_each_entry_from(rule, check->tcpcheck_rules->list, list) {
enum tcpcheck_eval_ret eval_ret;