MEDIUM: Attach tcpcheck_rules to check
This is to allow checks to be established whose tcpcheck_rules
are not those of its proxy.
Signed-off-by: Simon Horman <horms@verge.net.au>
diff --git a/src/checks.c b/src/checks.c
index 6624714..0f99d47 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -60,7 +60,7 @@
#include <proto/task.h>
static int httpchk_expect(struct server *s, int done);
-static int tcpcheck_get_step_id(struct server *);
+static int tcpcheck_get_step_id(struct check *);
static void tcpcheck_main(struct connection *);
static const struct check_status check_statuses[HCHK_STATUS_SIZE] = {
@@ -620,7 +620,7 @@
chk = get_trash_chunk();
if (check->type == PR_O2_TCPCHK_CHK) {
- step = tcpcheck_get_step_id(check->server);
+ step = tcpcheck_get_step_id(check);
if (!step)
chunk_printf(chk, " at initial connection step of tcp-check");
else {
@@ -1463,8 +1463,8 @@
/* 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(&s->proxy->tcpcheck_rules)) {
- struct tcpcheck_rule *r = (struct tcpcheck_rule *) s->proxy->tcpcheck_rules.n;
+ if (check->type == PR_O2_TCPCHK_CHK && !LIST_ISEMPTY(check->tcpcheck_rules)) {
+ struct tcpcheck_rule *r = (struct tcpcheck_rule *) check->tcpcheck_rules->n;
/* if first step is a 'connect', then tcpcheck_main must run it */
if (r->action == TCPCHK_ACT_CONNECT) {
tcpcheck_main(conn);
@@ -2351,23 +2351,23 @@
/*
* return the id of a step in a send/expect session
*/
-static int tcpcheck_get_step_id(struct server *s)
+static int tcpcheck_get_step_id(struct check *check)
{
struct tcpcheck_rule *cur = NULL, *next = NULL;
int i = 0;
/* not even started anything yet => step 0 = initial connect */
- if (!s->check.current_step)
+ if (check->current_step)
return 0;
- cur = s->check.last_started_step;
+ cur = check->last_started_step;
/* no step => first step */
if (cur == NULL)
return 1;
/* increment i until current step */
- list_for_each_entry(next, &s->proxy->tcpcheck_rules, list) {
+ list_for_each_entry(next, check->tcpcheck_rules, list) {
if (next->list.p == &cur->list)
break;
++i;
@@ -2384,7 +2384,7 @@
struct check *check = conn->owner;
struct server *s = check->server;
struct task *t = check->task;
- struct list *head = &s->proxy->tcpcheck_rules;
+ struct list *head = check->tcpcheck_rules;
/* here, we know that the check is complete or that it failed */
if (check->result != CHK_RES_UNKNOWN)
@@ -2565,14 +2565,14 @@
case SN_ERR_SRVTO: /* ETIMEDOUT */
case SN_ERR_SRVCL: /* ECONNREFUSED, ENETUNREACH, ... */
chunk_printf(&trash, "TCPCHK error establishing connection at step %d: %s",
- tcpcheck_get_step_id(s), strerror(errno));
+ tcpcheck_get_step_id(check), strerror(errno));
set_server_check_status(check, HCHK_STATUS_L4CON, trash.str);
goto out_end_tcpcheck;
case SN_ERR_PRXCOND:
case SN_ERR_RESOURCE:
case SN_ERR_INTERNAL:
chunk_printf(&trash, "TCPCHK error establishing connection at step %d",
- tcpcheck_get_step_id(s));
+ tcpcheck_get_step_id(check));
set_server_check_status(check, HCHK_STATUS_SOCKERR, trash.str);
goto out_end_tcpcheck;
}
@@ -2620,7 +2620,7 @@
if (check->current_step->string_len >= check->bo->size) {
chunk_printf(&trash, "tcp-check send : string too large (%d) for buffer size (%d) at step %d",
check->current_step->string_len, check->bo->size,
- tcpcheck_get_step_id(s));
+ tcpcheck_get_step_id(check));
set_server_check_status(check, HCHK_STATUS_L7RSP, trash.str);
goto out_end_tcpcheck;
}
@@ -2681,7 +2681,7 @@
/* empty response */
chunk_printf(&trash, "TCPCHK got an empty response at step %d",
- tcpcheck_get_step_id(s));
+ tcpcheck_get_step_id(check));
set_server_check_status(check, HCHK_STATUS_L7RSP, trash.str);
goto out_end_tcpcheck;
@@ -2706,12 +2706,12 @@
/* we were looking for a string */
if (cur->string != NULL) {
chunk_printf(&trash, "TCPCHK matched unwanted content '%s' at step %d",
- cur->string, tcpcheck_get_step_id(s));
+ cur->string, tcpcheck_get_step_id(check));
}
else {
/* we were looking for a regex */
chunk_printf(&trash, "TCPCHK matched unwanted content (regex) at step %d",
- tcpcheck_get_step_id(s));
+ tcpcheck_get_step_id(check));
}
set_server_check_status(check, HCHK_STATUS_L7RSP, trash.str);
goto out_end_tcpcheck;
@@ -2740,12 +2740,12 @@
/* we were looking for a string */
if (cur->string != NULL) {
chunk_printf(&trash, "TCPCHK did not match content '%s' at step %d",
- cur->string, tcpcheck_get_step_id(s));
+ cur->string, tcpcheck_get_step_id(check));
}
else {
/* we were looking for a regex */
chunk_printf(&trash, "TCPCHK did not match content (regex) at step %d",
- tcpcheck_get_step_id(s));
+ tcpcheck_get_step_id(check));
}
set_server_check_status(check, HCHK_STATUS_L7RSP, trash.str);
goto out_end_tcpcheck;