]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: applet: add appctx_strm() and appctx_cs() to access common fields
authorWilly Tarreau <w@1wt.eu>
Wed, 11 May 2022 12:14:56 +0000 (14:14 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 13 May 2022 12:28:48 +0000 (14:28 +0200)
It's very common to have to access a stream or a conn_stream from the
appctx, let's add trivial accessors for that.

include/haproxy/applet.h

index fdfc1ee021678d3cbd8fbca062df19d42601a520..185c1c19ccea6f1be73ba78a417a2301266b8dc8 100644 (file)
@@ -76,6 +76,20 @@ static inline void appctx_wakeup(struct appctx *appctx)
        task_wakeup(appctx->t, TASK_WOKEN_OTHER);
 }
 
+/* returns the conn_stream the appctx is attached to, via the endp */
+static inline struct conn_stream *appctx_cs(const struct appctx *appctx)
+{
+       return appctx->endp->cs;
+}
+
+/* returns the stream the appctx is attached to. Note that a stream *must*
+ * be attached, as we use an unchecked dereference via __cs_strm().
+ */
+static inline struct stream *appctx_strm(const struct appctx *appctx)
+{
+       return __cs_strm(appctx->endp->cs);
+}
+
 #endif /* _HAPROXY_APPLET_H */
 
 /*