]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: sink: use the generic context to store the forwarder's context
authorWilly Tarreau <w@1wt.eu>
Wed, 4 May 2022 18:42:23 +0000 (20:42 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 6 May 2022 16:13:36 +0000 (18:13 +0200)
Instead of having a struct that contains a single pointer in the appctx
context, let's directly use the generic context pointer and get rid of
the now unused sft.ptr entry.

include/haproxy/applet-t.h
src/sink.c

index e57305ff1fbc3ef86a1782256f4679cca610cdec..51186b523b5543cceabd3b57f404123a0578a8a2 100644 (file)
@@ -138,9 +138,6 @@ struct appctx {
                        /* all entries below are used by various CLI commands, please
                         * keep the grouped together and avoid adding new ones.
                         */
-                       struct {
-                               void *ptr;
-                       } sft; /* sink forward target */
                        struct {
                                struct httpclient *ptr;
                        } httpclient;
index 1ef2bacbf7ae9f5a703f7e33f6d66ebebcd3f8ec..65a218d635808a801caf619a58efa806f59507bd 100644 (file)
@@ -292,14 +292,15 @@ void sink_setup_proxy(struct proxy *px)
 }
 
 /*
- * IO Handler to handle message push to syslog tcp server
+ * IO Handler to handle message push to syslog tcp server.
+ * It takes its context from appctx->svcctx.
  */
 static void sink_forward_io_handler(struct appctx *appctx)
 {
        struct conn_stream *cs = appctx->owner;
        struct stream *s = __cs_strm(cs);
        struct sink *sink = strm_fe(s)->parent;
-       struct sink_forward_target *sft = appctx->ctx.sft.ptr;
+       struct sink_forward_target *sft = appctx->svcctx;
        struct ring *ring = sink->ctx.ring;
        struct buffer *buf = &ring->buf;
        uint64_t msg_len;
@@ -432,13 +433,14 @@ close:
 /*
  * IO Handler to handle message push to syslog tcp server
  * using octet counting frames
+ * It takes its context from appctx->svcctx.
  */
 static void sink_forward_oc_io_handler(struct appctx *appctx)
 {
        struct conn_stream *cs = appctx->owner;
        struct stream *s = __cs_strm(cs);
        struct sink *sink = strm_fe(s)->parent;
-       struct sink_forward_target *sft = appctx->ctx.sft.ptr;
+       struct sink_forward_target *sft = appctx->svcctx;
        struct ring *ring = sink->ctx.ring;
        struct buffer *buf = &ring->buf;
        uint64_t msg_len;
@@ -593,7 +595,7 @@ void __sink_forward_session_deinit(struct sink_forward_target *sft)
 
 static void sink_forward_session_release(struct appctx *appctx)
 {
-       struct sink_forward_target *sft = appctx->ctx.sft.ptr;
+       struct sink_forward_target *sft = appctx->svcctx;
 
        if (!sft)
                return;
@@ -620,6 +622,7 @@ static struct applet sink_forward_oc_applet = {
 
 /*
  * Create a new peer session in assigned state (connect will start automatically)
+ * It sets its context into appctx->svcctx.
  */
 static struct appctx *sink_forward_session_create(struct sink *sink, struct sink_forward_target *sft)
 {
@@ -638,7 +641,7 @@ static struct appctx *sink_forward_session_create(struct sink *sink, struct sink
        if (!appctx)
                goto out_close;
 
-       appctx->ctx.sft.ptr = (void *)sft;
+       appctx->svcctx = (void *)sft;
 
        sess = session_new(p, NULL, &appctx->obj_type);
        if (!sess) {