diff --git a/include/proto/obj_type.h b/include/proto/obj_type.h index cc35d5cdd..c1ac5f424 100644 --- a/include/proto/obj_type.h +++ b/include/proto/obj_type.h @@ -32,6 +32,7 @@ #include #include #include +#include static inline enum obj_type obj_type(const enum obj_type *t) { @@ -53,6 +54,7 @@ static inline const char *obj_type_name(const enum obj_type *t) case OBJ_TYPE_SRVRQ: return "SRVRQ"; case OBJ_TYPE_CS: return "CS"; case OBJ_TYPE_STREAM: return "STREAM"; + case OBJ_TYPE_CHECK: return "CHECK"; default: return "!INVAL!"; } } @@ -172,6 +174,18 @@ static inline struct stream *objt_stream(enum obj_type *t) return __objt_stream(t); } +static inline struct check *__objt_check(enum obj_type *t) +{ + return container_of(t, struct check, obj_type); +} + +static inline struct check *objt_check(enum obj_type *t) +{ + if (!t || *t != OBJ_TYPE_CHECK) + return NULL; + return __objt_check(t); +} + static inline void *obj_base_ptr(enum obj_type *t) { switch (obj_type(t)) { @@ -184,6 +198,7 @@ static inline void *obj_base_ptr(enum obj_type *t) case OBJ_TYPE_CONN: return __objt_conn(t); case OBJ_TYPE_SRVRQ: return __objt_dns_srvrq(t); case OBJ_TYPE_CS: return __objt_cs(t); + case OBJ_TYPE_CHECK: return __objt_check(t); default: return t; // exact pointer for invalid case } } diff --git a/include/types/checks.h b/include/types/checks.h index f52e4a4d8..d1a53ed2b 100644 --- a/include/types/checks.h +++ b/include/types/checks.h @@ -158,6 +158,7 @@ enum { }; struct check { + enum obj_type obj_type; /* object type == OBJ_TYPE_CHECK */ struct session *sess; /* Health check session. */ struct vars vars; /* Health check dynamic variables. */ struct xprt_ops *xprt; /* transport layer operations for health checks */ diff --git a/include/types/obj_type.h b/include/types/obj_type.h index 94107181e..da3e735ba 100644 --- a/include/types/obj_type.h +++ b/include/types/obj_type.h @@ -42,6 +42,7 @@ enum obj_type { OBJ_TYPE_SRVRQ, /* object is a struct dns_srvrq */ OBJ_TYPE_CS, /* object is a struct conn_stream */ OBJ_TYPE_STREAM, /* object is a struct stream */ + OBJ_TYPE_CHECK, /* object is a struct check */ OBJ_TYPE_ENTRIES /* last one : number of entries */ } __attribute__((packed)) ; diff --git a/src/server.c b/src/server.c index e3a74498d..14eb41f9d 100644 --- a/src/server.c +++ b/src/server.c @@ -1758,11 +1758,13 @@ struct server *new_server(struct proxy *proxy) srv->next_state = SRV_ST_RUNNING; /* early server setup */ srv->last_change = now.tv_sec; + srv->check.obj_type = OBJ_TYPE_CHECK; srv->check.status = HCHK_STATUS_INI; srv->check.server = srv; srv->check.proxy = proxy; srv->check.tcpcheck_rules = &proxy->tcpcheck_rules; + srv->agent.obj_type = OBJ_TYPE_CHECK; srv->agent.status = HCHK_STATUS_INI; srv->agent.server = srv; srv->agent.proxy = proxy;