From: Willy Tarreau Date: Thu, 12 Jan 2023 18:18:34 +0000 (+0100) Subject: MINOR: listener: remove the useless ->default_target field X-Git-Tag: v2.8-dev3~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5983cef80ddcda9bfd9a563e24355ac752bc09f;p=thirdparty%2Fhaproxy.git MINOR: listener: remove the useless ->default_target field 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). --- diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h index 25449e451c..6edb52e51b 100644 --- a/include/haproxy/listener-t.h +++ b/include/haproxy/listener-t.h @@ -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 */ diff --git a/src/cfgparse.c b/src/cfgparse.c index 88e772871b..666d5c33b5 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -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; diff --git a/src/cli.c b/src/cli.c index c917ea21ec..4b78fdac1b 100644 --- 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 */ diff --git a/src/log.c b/src/log.c index b64262148a..04ead1f6bb 100644 --- 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++; diff --git a/src/stream.c b/src/stream.c index ce90151bdf..19e54b6662 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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;