summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2020-10-07 16:52:43 +0200
committerWilly Tarreau <w@1wt.eu>2020-10-07 19:42:32 +0200
commit456e906b9ec9b81c6453380c8e2893a3450c1647 (patch)
treecb7c4f0691928c51d9ed6f36ca00e1043a7b4462
parentaac15f6a2a1d78542627630f58da09d29f2ab60f (diff)
downloadhaproxy-456e906b9ec9b81c6453380c8e2893a3450c1647.tar.gz
MEDIUM: proxy: make soft_stop() stop most listeners using protocol_stop_now()
One difficulty in soft-stopping is to make sure not to forget unlisted listeners. By first doing a pass using protocol_stop_now() we catch the vast majority of them. The few remaining ones are the ones belonging to a proxy having a grace period. For these ones, the proxy will arm its stop_time timer and emit a log message. Since neither UDP listeners nor peers use the grace period, we can already get rid of the special cases there since we know they will have been stopped by the protocols.
-rw-r--r--src/proxy.c36
1 files changed, 7 insertions, 29 deletions
diff --git a/src/proxy.c b/src/proxy.c
index e3f2ce857..eaebc5b97 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -35,6 +35,7 @@
#include <haproxy/obj_type-t.h>
#include <haproxy/peers.h>
#include <haproxy/pool.h>
+#include <haproxy/protocol.h>
#include <haproxy/proto_tcp.h>
#include <haproxy/proxy.h>
#include <haproxy/server-t.h>
@@ -1227,7 +1228,6 @@ struct task *hard_stop(struct task *t, void *context, unsigned short state)
void soft_stop(void)
{
struct proxy *p;
- struct peers *prs;
struct task *task;
stopping = 1;
@@ -1243,6 +1243,12 @@ void soft_stop(void)
ha_alert("out of memory trying to allocate the hard-stop task.\n");
}
}
+
+ /* stop all stoppable listeners, resulting in disabling all proxies
+ * that don't use a grace period.
+ */
+ protocol_stop_now();
+
p = proxies_list;
tv_update_date(0,1); /* else, the old time before select will be used */
while (p) {
@@ -1263,34 +1269,6 @@ void soft_stop(void)
p = p->next;
}
- prs = cfg_peers;
- while (prs) {
- if (prs->peers_fe)
- stop_proxy(prs->peers_fe);
- prs = prs->next;
- }
-
- p = cfg_log_forward;
- while (p) {
- /* Zombie proxy, let's close the file descriptors */
- if (p->disabled &&
- !LIST_ISEMPTY(&p->conf.listeners) &&
- LIST_ELEM(p->conf.listeners.n,
- struct listener *, by_fe)->state > LI_ASSIGNED) {
- struct listener *l;
- list_for_each_entry(l, &p->conf.listeners, by_fe) {
- if (l->state > LI_ASSIGNED)
- close(l->rx.fd);
- l->state = LI_INIT;
- }
- }
-
- if (!p->disabled) {
- stop_proxy(p);
- }
- p = p->next;
- }
-
/* signal zero is used to broadcast the "stopping" event */
signal_handler(0);
}