struct tcpcheck_rule {
struct list list; /* list linked to from the proxy */
enum tcpcheck_rule_type action; /* type of the rule. */
+ int index; /* Index within the list. Starts at 0. */
char *comment; /* comment to be used in the logs and on the stats socket */
char *string; /* sent string */
int string_len; /* sent string length */
*/
static int tcpcheck_get_step_id(struct check *check)
{
- struct tcpcheck_rule *cur;
- int i = 0;
-
/* not even started anything yet => step 0 = initial connect */
if (!check->current_step && !check->last_started_step)
return 0;
if (!check->last_started_step)
return 1;
- list_for_each_entry(cur, check->tcpcheck_rules, list) {
- if (cur->list.p == &check->last_started_step->list)
- break;
- i++;
- }
- return i;
+ return check->last_started_step->index + 1;
}
/*
{
struct list *rules = curpx->tcpcheck_rules;
struct tcpcheck_rule *chk = NULL;
- int cur_arg, ret = 0;
+ int index, cur_arg, ret = 0;
if (warnifnotcap(curpx, PR_CAP_BE, file, line, args[0], NULL))
ret = 1;
curpx->tcpcheck_rules = rules;
}
+ index = 0;
+ if (!LIST_ISEMPTY(rules)) {
+ chk = LIST_PREV(rules, typeof(chk), list);
+ index = chk->index + 1;
+ }
+
cur_arg = 1;
if (strcmp(args[cur_arg], "connect") == 0)
chk = parse_tcpcheck_connect(args, cur_arg, curpx, rules, errmsg);
ret = (*errmsg != NULL); /* Handle warning */
/* No error: add the tcp-check rule in the list */
+ chk->index = index;
LIST_ADDQ(rules, &chk->list);
return ret;