From 0788f47cc1c31e8c1cb0360ae53e778271b432ed Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 24 Oct 2013 22:45:25 +0200 Subject: [PATCH] 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. --- include/proto/obj_type.h | 14 ++++++++++++++ include/types/obj_type.h | 1 + include/types/stream_interface.h | 1 + 3 files changed, 16 insertions(+) diff --git a/include/proto/obj_type.h b/include/proto/obj_type.h index 8b180f28d..a02e1d692 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 88d897358..09eaf4364 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 1c986ba2f..1af5be51d 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 */