mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-01-30 06:22:00 +01:00
BUG/MINOR: tcp-check: don't initialize then break a connection starting with a comment
The following config :
backend tcp9000
option tcp-check
tcp-check comment "this is a comment"
tcp-check connect port 10000
server srv 127.0.0.1:9000 check inter 1s
will result in a connection being first made to port 9000 then immediately
destroyed and re-created on port 10000, because the first rule is a comment
and doesn't match the test for the first rule being a connect(). It's
mostly harmless (unless the server really must not receive empty
connections) and the workaround simply consists in removing the comment.
Let's proceed like in other places where we simply skip leading comments.
A new function was made to make this lookup les boring. The fix should be
backported to 1.7 and 1.6.
This commit is contained in:
parent
59070784fc
commit
894c642fbf
34
src/checks.c
34
src/checks.c
@ -1447,6 +1447,20 @@ static struct task *server_warmup(struct task *t)
|
||||
return t;
|
||||
}
|
||||
|
||||
/* returns the first NON-COMMENT tcp-check rule from list <list> or NULL if
|
||||
* none was found.
|
||||
*/
|
||||
static struct tcpcheck_rule *get_first_tcpcheck_rule(struct list *list)
|
||||
{
|
||||
struct tcpcheck_rule *r;
|
||||
|
||||
list_for_each_entry(r, list, list) {
|
||||
if (r->action != TCPCHK_ACT_COMMENT)
|
||||
return r;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* establish a server health-check that makes use of a connection.
|
||||
*
|
||||
@ -1544,18 +1558,18 @@ static int connect_conn_chk(struct task *t)
|
||||
/* only plain tcp-check supports quick ACK */
|
||||
quickack = check->type == 0 || check->type == PR_O2_TCPCHK_CHK;
|
||||
|
||||
if (check->type == PR_O2_TCPCHK_CHK && !LIST_ISEMPTY(check->tcpcheck_rules)) {
|
||||
struct tcpcheck_rule *r;
|
||||
if (check->type == PR_O2_TCPCHK_CHK) {
|
||||
struct tcpcheck_rule *r = get_first_tcpcheck_rule(check->tcpcheck_rules);
|
||||
|
||||
r = LIST_NEXT(check->tcpcheck_rules, struct tcpcheck_rule *, list);
|
||||
|
||||
/* if first step is a 'connect', then tcpcheck_main must run it */
|
||||
if (r->action == TCPCHK_ACT_CONNECT) {
|
||||
tcpcheck_main(conn);
|
||||
return SF_ERR_UP;
|
||||
if (r) {
|
||||
/* if first step is a 'connect', then tcpcheck_main must run it */
|
||||
if (r->action == TCPCHK_ACT_CONNECT) {
|
||||
tcpcheck_main(conn);
|
||||
return SF_ERR_UP;
|
||||
}
|
||||
if (r->action == TCPCHK_ACT_EXPECT)
|
||||
quickack = 0;
|
||||
}
|
||||
if (r->action == TCPCHK_ACT_EXPECT)
|
||||
quickack = 0;
|
||||
}
|
||||
|
||||
ret = SF_ERR_INTERNAL;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user