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.
*
/* 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;
-
- r = LIST_NEXT(check->tcpcheck_rules, struct tcpcheck_rule *, list);
+ if (check->type == PR_O2_TCPCHK_CHK) {
+ struct tcpcheck_rule *r = get_first_tcpcheck_rule(check->tcpcheck_rules);
- /* 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;