MINOR: checks: Use the check as origin when a session is created
Before, the server was used as origin during session creation. It was only used
to get the check associated to the server when a variable is get or set in the
check scope or when a check sample fetch was called. So it seems easier to use
the check as origin of a session. It is also more logical becaues the session is
created by the health-check itself and not its server.
diff --git a/src/checks.c b/src/checks.c
index fb4c962..58bc88d 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -3364,7 +3364,7 @@
struct tcpcheck_var *var;
/* First evaluation, create a session */
- check->sess = session_new(&checks_fe, NULL, (check->server ? &check->server->obj_type : NULL));
+ check->sess = session_new(&checks_fe, NULL, &check->obj_type);
if (!check->sess) {
chunk_printf(&trash, "TCPCHK error allocating check session");
set_server_check_status(check, HCHK_STATUS_SOCKERR, trash.area);
@@ -4457,13 +4457,13 @@
{
unsigned int buf_offset = ((arg_p[0].type == ARGT_SINT) ? arg_p[0].data.sint : 0);
unsigned int buf_size = ((arg_p[1].type == ARGT_SINT) ? arg_p[1].data.sint : 0);
- struct server *srv = (smp->sess ? objt_server(smp->sess->origin) : NULL);
+ struct check *check = (smp->sess ? objt_check(smp->sess->origin) : NULL);
struct buffer *buf;
- if (!srv || !srv->do_check)
+ if (!check)
return 0;
- buf = &srv->check.bi;
+ buf = &check->bi;
if (buf_offset > b_data(buf))
goto no_match;
if (buf_offset + buf_size > b_data(buf))