From: Willy Tarreau Date: Thu, 24 Oct 2013 20:45:25 +0000 (+0200) Subject: MINOR: obj: introduce a new type appctx X-Git-Tag: v1.5-dev20~120 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0788f47cc1c31e8c1cb0360ae53e778271b432ed;p=thirdparty%2Fhaproxy.git MINOR: obj: introduce a new type appctx The object type was added to "struct appctx". The purpose will be to identify an appctx when the applet context is detached from the stream interface. For now, it's still attached, so this patch only adds the new type and does not replace its use. --- diff --git a/include/proto/obj_type.h b/include/proto/obj_type.h index 8b180f28d4..a02e1d6923 100644 --- a/include/proto/obj_type.h +++ b/include/proto/obj_type.h @@ -45,6 +45,7 @@ static inline const char *obj_type_name(enum obj_type *t) case OBJ_TYPE_PROXY: return "PROXY"; case OBJ_TYPE_SERVER: return "SERVER"; case OBJ_TYPE_APPLET: return "APPLET"; + case OBJ_TYPE_APPCTX: return "APPCTX"; case OBJ_TYPE_CONN: return "CONN"; default: return "NONE"; } @@ -105,6 +106,18 @@ static inline struct si_applet *objt_applet(enum obj_type *t) return __objt_applet(t); } +static inline struct appctx *__objt_appctx(enum obj_type *t) +{ + return container_of(t, struct appctx, obj_type); +} + +static inline struct appctx *objt_appctx(enum obj_type *t) +{ + if (!t || *t != OBJ_TYPE_APPCTX) + return NULL; + return __objt_appctx(t); +} + static inline struct connection *__objt_conn(enum obj_type *t) { return container_of(t, struct connection, obj_type); @@ -124,6 +137,7 @@ static inline void *obj_base_ptr(enum obj_type *t) case OBJ_TYPE_PROXY: return __objt_proxy(t); case OBJ_TYPE_SERVER: return __objt_server(t); case OBJ_TYPE_APPLET: return __objt_applet(t); + case OBJ_TYPE_APPCTX: return __objt_appctx(t); case OBJ_TYPE_CONN: return __objt_conn(t); default: return NULL; } diff --git a/include/types/obj_type.h b/include/types/obj_type.h index 88d897358b..09eaf4364b 100644 --- a/include/types/obj_type.h +++ b/include/types/obj_type.h @@ -37,6 +37,7 @@ enum obj_type { OBJ_TYPE_PROXY, /* object is a struct proxy */ OBJ_TYPE_SERVER, /* object is a struct server */ OBJ_TYPE_APPLET, /* object is a struct si_applet */ + OBJ_TYPE_APPCTX, /* object is a struct appctx */ OBJ_TYPE_CONN, /* object is a struct connection */ OBJ_TYPE_ENTRIES /* last one : number of entries */ }; diff --git a/include/types/stream_interface.h b/include/types/stream_interface.h index 1c986ba2fe..1af5be51d5 100644 --- a/include/types/stream_interface.h +++ b/include/types/stream_interface.h @@ -91,6 +91,7 @@ struct si_ops { /* Context of a running applet. */ struct appctx { + enum obj_type obj_type; /* OBJ_TYPE_APPCTX */ unsigned int st0; /* CLI state for stats, session state for peers */ unsigned int st1; /* prompt for stats, session error for peers */ unsigned int st2; /* output state for stats, unused by peers */