BUG/MINOR: tcpcheck: Disable QUICKACK only if data should be sent after connect
It is only a real problem for agent-checks when there is no agent string to
send. The condition to disable TCP_QUICKACK was only based on the action
type following the connect one. But it is not always accurate. indeed, for
agent-checks, there is always a SEND action. But if there is no "agent-send"
string defined, nothing is sent. In this case, this adds 200ms of latency
with no reason.
To fix the bug, a flag is now used on the CONNECT action to instruct there
are data that should be sent after the connect. For health-checks, this flag
is set if the action following the connect is a SEND action. For
agent-checks, it is set if an "agent-send" string is defined.
This patch should fix the issue #1836. It must be backported as far as 2.2.
diff --git a/src/tcpcheck.c b/src/tcpcheck.c
index f254c80..7e7627a 100644
--- a/src/tcpcheck.c
+++ b/src/tcpcheck.c
@@ -1187,10 +1187,8 @@
if (proto && proto->connect) {
int flags = 0;
- if (check->tcpcheck_rules->flags & TCPCHK_RULES_PROTO_CHK)
- flags |= CONNECT_HAS_DATA;
- if (!next || next->action != TCPCHK_ACT_EXPECT)
- flags |= CONNECT_DELACK_ALWAYS;
+ if (connect->options & TCPCHK_OPT_HAS_DATA)
+ flags = (CONNECT_HAS_DATA|CONNECT_DELACK_ALWAYS);
status = proto->connect(conn, flags);
}
@@ -3737,6 +3735,8 @@
* comment is assigned to the following rule(s).
*/
list_for_each_entry_safe(chk, back, px->tcpcheck_rules.list, list) {
+ struct tcpcheck_rule *next;
+
if (chk->action != prev_action && prev_action != TCPCHK_ACT_COMMENT)
ha_free(&comment);
@@ -3751,6 +3751,9 @@
case TCPCHK_ACT_CONNECT:
if (!chk->comment && comment)
chk->comment = strdup(comment);
+ next = get_next_tcpcheck_rule(&px->tcpcheck_rules, chk);
+ if (next && next->action == TCPCHK_ACT_SEND)
+ chk->connect.options |= TCPCHK_OPT_HAS_DATA;
/* fall through */
case TCPCHK_ACT_ACTION_KW:
ha_free(&comment);