]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: obj: introduce a new type appctx
authorWilly Tarreau <w@1wt.eu>
Thu, 24 Oct 2013 20:45:25 +0000 (22:45 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 9 Dec 2013 14:40:22 +0000 (15:40 +0100)
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
include/types/obj_type.h
include/types/stream_interface.h

index 8b180f28d4576183f90759a8fb8b6baf64a23f78..a02e1d6923a6cde6a7ac678be068a45bc582b25c 100644 (file)
@@ -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;
        }
index 88d897358b94a64dae7f9cd08bc4e24cb79368d2..09eaf4364bdd84463f4efeaf7ed1df190b1bc8f6 100644 (file)
@@ -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 */
 };
index 1c986ba2fe5adccfaeddf07a10cb2c5220d0e3e1..1af5be51d5beca7dad58103d73c9a29fc63aa14b 100644 (file)
@@ -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  */