From: Christopher Faulet Date: Wed, 24 Apr 2024 12:36:17 +0000 (+0200) Subject: MINOR: applet: Add a function to know the side where an applet was created X-Git-Tag: v3.0-dev9~56 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bea541b70aa9e47c051760e6010f34ec202fb722;p=thirdparty%2Fhaproxy.git MINOR: applet: Add a function to know the side where an applet was created appctx_is_back() function may be used to know if an applet was create on frontend side or on backend side. It may be handy for some applets that may exist on both sides, like peer applets. --- diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h index 7f71083ee1..705a8837e8 100644 --- a/include/haproxy/applet.h +++ b/include/haproxy/applet.h @@ -153,6 +153,16 @@ static inline struct stream *appctx_strm(const struct appctx *appctx) return __sc_strm(appctx->sedesc->sc); } +/* returns 1 if the appctx is attached on the backend side or 0 if it is + * attached on the frontend side. Note that only frontend appctx may have no SC. + */ +static inline int appctx_is_back(const struct appctx *appctx) +{ + struct stconn *sc = appctx_sc(appctx); + + return !!(sc && (sc->flags & SC_FL_ISBACK)); +} + static forceinline void applet_fl_zero(struct appctx *appctx) { appctx->flags = 0;