MINOR: checks: Store the proxy in checks.
Instead of assuming we have a server, store the proxy directly in struct
check, and use it instead of s->server.
This should be a no-op for now, but will be useful later when we change
mail checks to avoid having a server.
This should be backported to 1.9.
diff --git a/include/types/checks.h b/include/types/checks.h
index 6346fe3..f89abcb 100644
--- a/include/types/checks.h
+++ b/include/types/checks.h
@@ -180,6 +180,7 @@
int send_string_len; /* length of agent command string */
char *send_string; /* optionally send a string when connecting to the agent */
struct server *server; /* back-pointer to server */
+ struct proxy *proxy; /* proxy to be used */
char **argv; /* the arguments to use if running a process-based check */
char **envp; /* the environment to use if running a process-based check */
struct pid_list *curpid; /* entry in pid_list used for current process-based test, or -1 if not in test */
diff --git a/src/checks.c b/src/checks.c
index 4baaf9f..edb61b4 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -2124,7 +2124,7 @@
static struct task *process_chk_conn(struct task *t, void *context, unsigned short state)
{
struct check *check = context;
- struct server *s = check->server;
+ struct proxy *proxy = check->proxy;
struct conn_stream *cs = check->cs;
struct connection *conn = cs_conn(cs);
int rv;
@@ -2142,7 +2142,7 @@
* is disabled.
*/
if (((check->state & (CHK_ST_ENABLED | CHK_ST_PAUSED)) != CHK_ST_ENABLED) ||
- s->proxy->state == PR_STSTOPPED)
+ proxy->state == PR_STSTOPPED)
goto reschedule;
/* we'll initiate a new check */
@@ -2167,8 +2167,8 @@
*/
t->expire = tick_add(now_ms, MS_TO_TICKS(check->inter));
- if (s->proxy->timeout.check && s->proxy->timeout.connect) {
- int t_con = tick_add(now_ms, s->proxy->timeout.connect);
+ if (proxy->timeout.check && proxy->timeout.connect) {
+ int t_con = tick_add(now_ms, proxy->timeout.connect);
t->expire = tick_first(t->expire, t_con);
}
@@ -2213,10 +2213,10 @@
while (tick_is_expired(t->expire, now_ms)) {
int t_con;
- t_con = tick_add(t->expire, s->proxy->timeout.connect);
+ t_con = tick_add(t->expire, proxy->timeout.connect);
t->expire = tick_add(t->expire, MS_TO_TICKS(check->inter));
- if (s->proxy->timeout.check)
+ if (proxy->timeout.check)
t->expire = tick_first(t->expire, t_con);
}
}
@@ -2609,6 +2609,7 @@
struct conn_stream *cs = check->cs;
struct connection *conn = cs_conn(cs);
struct server *s = check->server;
+ struct proxy *proxy = check->proxy;
struct task *t = check->task;
struct list *head = check->tcpcheck_rules;
int retcode = 0;
@@ -2647,10 +2648,10 @@
while (tick_is_expired(t->expire, now_ms)) {
int t_con;
- t_con = tick_add(t->expire, s->proxy->timeout.connect);
+ t_con = tick_add(t->expire, proxy->timeout.connect);
t->expire = tick_add(t->expire, MS_TO_TICKS(check->inter));
- if (s->proxy->timeout.check)
+ if (proxy->timeout.check)
t->expire = tick_first(t->expire, t_con);
}
goto out;
@@ -2669,8 +2670,8 @@
b_reset(&check->bi);
check->current_step = next;
t->expire = tick_add(now_ms, MS_TO_TICKS(check->inter));
- if (s->proxy->timeout.check)
- t->expire = tick_add_ifset(now_ms, s->proxy->timeout.check);
+ if (proxy->timeout.check)
+ t->expire = tick_add_ifset(now_ms, proxy->timeout.check);
}
while (1) {
@@ -2790,7 +2791,7 @@
}
conn_prepare(conn, proto, xprt);
- conn_install_mux(conn, &mux_pt_ops, cs, s->proxy, NULL);
+ conn_install_mux(conn, &mux_pt_ops, cs, proxy, NULL);
cs_attach(cs, check, &check_conn_cb);
ret = SF_ERR_INTERNAL;
@@ -2822,8 +2823,8 @@
*/
t->expire = tick_add(now_ms, MS_TO_TICKS(check->inter));
- if (s->proxy->timeout.check && s->proxy->timeout.connect) {
- int t_con = tick_add(now_ms, s->proxy->timeout.connect);
+ if (proxy->timeout.check && proxy->timeout.connect) {
+ int t_con = tick_add(now_ms, proxy->timeout.connect);
t->expire = tick_first(t->expire, t_con);
}
break;
@@ -3062,10 +3063,10 @@
while (tick_is_expired(t->expire, now_ms)) {
int t_con;
- t_con = tick_add(t->expire, s->proxy->timeout.connect);
+ t_con = tick_add(t->expire, proxy->timeout.connect);
t->expire = tick_add(t->expire, MS_TO_TICKS(check->inter));
- if (s->proxy->timeout.check)
+ if (proxy->timeout.check)
t->expire = tick_first(t->expire, t_con);
}
goto out;
@@ -3219,6 +3220,7 @@
HA_SPIN_INIT(&q->lock);
check->inter = mls->timeout.mail;
check->rise = DEF_AGENT_RISETIME;
+ check->proxy = p;
check->fall = DEF_AGENT_FALLTIME;
if ((err_str = init_check(check, PR_O2_TCPCHK_CHK))) {
memprintf(err, "%s", err_str);
diff --git a/src/server.c b/src/server.c
index bc9e805..d4c48fb 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1721,6 +1721,7 @@
srv->check.status = HCHK_STATUS_INI;
srv->check.server = srv;
+ srv->check.proxy = proxy;
srv->check.tcpcheck_rules = &proxy->tcpcheck_rules;
srv->agent.status = HCHK_STATUS_INI;