MINOR: listener: remove the useless ->default_target field
authorWilly Tarreau <w@1wt.eu>
Thu, 12 Jan 2023 18:18:34 +0000 (19:18 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Feb 2023 17:00:20 +0000 (18:00 +0100)
This field is used by stream_new() to optionally set the applet the
stream will connect to for simple proxies like the CLI for example.
But it has never been configurable to anything and is always strictly
equal to the frontend's ->default_target. Let's just drop it and make
stream_new() only use the frontend's. It makes more sense anyway as
we don't want the proxy to work differently based on the "bind" line.
This idea was brought in 1.6 hoping that the h2 implementation would
use applets for decoding (which was dropped after the very first
attempt in 1.8).

include/haproxy/listener-t.h
src/cfgparse.c
src/cli.c
src/log.c
src/stream.c

index 25449e4..6edb52e 100644 (file)
@@ -245,7 +245,6 @@ struct listener {
 
        struct fe_counters *counters;   /* statistics counters */
        int nbconn;                     /* current number of connections on this listener */
-       enum obj_type *default_target;  /* default target to use for accepted sessions or NULL */
        /* cache line boundary */
        struct mt_list wait_queue;      /* link element to make the listener wait for something (LI_LIMITED)  */
        unsigned int thr_idx;           /* thread indexes for queue distribution : (t2<<16)+t1 */
index 88e7728..666d5c3 100644 (file)
@@ -747,7 +747,6 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                         * Newly allocated listener is at the end of the list
                         */
                        l = LIST_ELEM(bind_conf->listeners.p, typeof(l), by_bind);
-                       l->default_target = curpeers->peers_fe->default_target;
                        l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
                        global.maxsock++; /* for the listening socket */
 
@@ -972,7 +971,6 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                 * Newly allocated listener is at the end of the list
                 */
                l = LIST_ELEM(bind_conf->listeners.p, typeof(l), by_bind);
-               l->default_target = curpeers->peers_fe->default_target;
                l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
                global.maxsock++; /* for the listening socket */
        }
@@ -4329,8 +4327,6 @@ init_proxies_list_stage2:
                        }
 #endif
 
-                       listener->default_target = curproxy->default_target;
-
                        if (!LIST_ISEMPTY(&curproxy->tcp_req.l4_rules))
                                listener->options |= LI_O_TCP_L4_RULES;
 
index c917ea2..4b78fda 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -552,8 +552,8 @@ static int cli_parse_global(char **args, int section_type, struct proxy *curpx,
                }
 
                bind_conf->accept = session_accept_fd;
+
                list_for_each_entry(l, &bind_conf->listeners, by_bind) {
-                       l->default_target = global.cli_fe->default_target;
                        l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
                        l->nice = -64;  /* we want to boost priority for local stats */
                        global.maxsock++; /* for the listening socket */
@@ -3045,8 +3045,8 @@ struct bind_conf *mworker_cli_proxy_new_listener(char *line)
 
 
        bind_conf->accept = session_accept_fd;
+
        list_for_each_entry(l, &bind_conf->listeners, by_bind) {
-               l->default_target = mworker_proxy->default_target;
                /* don't make the peers subject to global limits and don't close it in the master */
                l->options  |= LI_O_UNLIMITED;
                l->rx.flags |= RX_F_MWORKER; /* we are keeping this FD in the master */
@@ -3112,8 +3112,8 @@ int mworker_cli_sockpair_new(struct mworker_proc *mworker_proc, int proc)
        ha_free(&path);
 
        bind_conf->accept = session_accept_fd;
+
        list_for_each_entry(l, &bind_conf->listeners, by_bind) {
-               l->default_target = global.cli_fe->default_target;
                l->options |= (LI_O_UNLIMITED | LI_O_NOSTOP);
                HA_ATOMIC_INC(&unstoppable_jobs);
                /* it's a sockpair but we don't want to keep the fd in the master */
index b642621..04ead1f 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -3826,7 +3826,6 @@ int cfg_parse_log_forward(const char *file, int linenum, char **args, int kwm)
                        }
                }
                list_for_each_entry(l, &bind_conf->listeners, by_bind) {
-                       l->default_target = cfg_log_forward->default_target;
                        global.maxsock++;
                }
                cur_arg++;
index ce90151..19e54b6 100644 (file)
@@ -491,7 +491,7 @@ struct stream *stream_new(struct session *sess, struct stconn *sc, struct buffer
        }
 
        stream_init_srv_conn(s);
-       s->target = sess->listener ? sess->listener->default_target : NULL;
+       s->target = sess->fe->default_target;
 
        s->pend_pos = NULL;
        s->priority_class = 0;