]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sink: don't rely on p->parent in sink appctx
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 14 Sep 2023 22:29:53 +0000 (00:29 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 6 Oct 2023 13:34:31 +0000 (15:34 +0200)
Removing unnecessary dependency on proxy->parent pointer in
sink appctx functions by directly using the sink sft from the
applet->svcctx to get back to sink related structs.

Thanks to this, proxy used for a ringbuf does not have to be exclusive
to a single sink anymore.

src/sink.c

index 4b458279ecebf4914d04635ab9b67e731b867405..a75cb7ed2bb04114311eafba324fe21b43f3924a 100644 (file)
@@ -314,9 +314,8 @@ void sink_setup_proxy(struct proxy *px)
 static void sink_forward_io_handler(struct appctx *appctx)
 {
        struct stconn *sc = appctx_sc(appctx);
-       struct stream *s = __sc_strm(sc);
-       struct sink *sink = strm_fe(s)->parent;
        struct sink_forward_target *sft = appctx->svcctx;
+       struct sink *sink = sft->sink;
        struct ring *ring = sink->ctx.ring;
        struct buffer *buf = &ring->buf;
        uint64_t msg_len;
@@ -445,9 +444,8 @@ close:
 static void sink_forward_oc_io_handler(struct appctx *appctx)
 {
        struct stconn *sc = appctx_sc(appctx);
-       struct stream *s = __sc_strm(sc);
-       struct sink *sink = strm_fe(s)->parent;
        struct sink_forward_target *sft = appctx->svcctx;
+       struct sink *sink = sft->sink;
        struct ring *ring = sink->ctx.ring;
        struct buffer *buf = &ring->buf;
        uint64_t msg_len;
@@ -567,10 +565,9 @@ close:
 
 void __sink_forward_session_deinit(struct sink_forward_target *sft)
 {
-       struct stream *s = appctx_strm(sft->appctx);
        struct sink *sink;
 
-       sink = strm_fe(s)->parent;
+       sink = sft->sink;
        if (!sink)
                return;
 
@@ -838,9 +835,6 @@ static struct sink *sink_new_ringbuf(const char *id, const char *description,
        /* link sink to proxy */
        sink->forward_px = p;
 
-       /* link proxy to sink */
-       p->parent = sink;
-
        return sink;
 
  err: