]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sink: refine forward_px usage
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 14 Sep 2023 23:49:08 +0000 (01:49 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 6 Oct 2023 13:34:31 +0000 (15:34 +0200)
now forward_px only serves as a hint to know if a proxy was created
specifically for the sink, in which case the sink is responsible for it.

Everywhere forward_px was used in appctx context: get the parent proxy from
the sft->srv instead.

This permits to finally get rid of the double link dependency between sink
and proxy.

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

index b5138c85da810f0af07f3a0cb917f19644e461a9..79a0ddade6767dec6a347831f780d0a4d4ed054a 100644 (file)
@@ -54,7 +54,7 @@ struct sink {
        enum log_fmt fmt;          // format expected by the sink
        enum sink_type type;       // type of storage
        uint32_t maxlen;           // max message length (truncated above)
-       struct proxy* forward_px;  // proxy used to forward
+       struct proxy* forward_px;  // internal proxy used to forward (only set when exclusive to sink)
        struct sink_forward_target *sft; // sink forward targets
        struct task *forward_task; // task to handle forward targets conns
        struct sig_handler *forward_sighandler; /* signal handler */
index ae64b5537cc2bfa80ceeb12dd5e1a1d416de2574..d456ca20ff0ef8b270746dec3b5369f83a7112f5 100644 (file)
@@ -588,7 +588,7 @@ static int sink_forward_session_init(struct appctx *appctx)
        if (!sockaddr_alloc(&addr, &sft->srv->addr, sizeof(sft->srv->addr)))
                goto out_error;
 
-       if (appctx_finalize_startup(appctx, sft->sink->forward_px, &BUF_NULL) == -1)
+       if (appctx_finalize_startup(appctx, sft->srv->proxy, &BUF_NULL) == -1)
                goto out_free_addr;
 
        s = appctx_strm(appctx);
@@ -803,7 +803,9 @@ static void sink_free(struct sink *sink)
 }
 
 /* Helper function to create new high-level ring buffer (as in ring section from
- * the config)
+ * the config): will create a new sink of buf type, and a new forward proxy,
+ * which will be stored in forward_px to know that the sink is responsible for
+ * it.
  *
  * Returns NULL on failure
  */