MEDIUM: listeners: support unstoppable listener
An unstoppable listener is a listener which won't be stop during a soft
stop. The unstoppable_jobs variable is incremented and the listener
won't prevent the process to leave properly.
It is not a good idea to use this feature (the LI_O_NOSTOP flag) with a
listener that need to be bind again on another process during a soft
reload.
diff --git a/include/types/listener.h b/include/types/listener.h
index 50f1936..eac2037 100644
--- a/include/types/listener.h
+++ b/include/types/listener.h
@@ -101,6 +101,7 @@
#define LI_O_ACC_CIP 0x1000 /* find the proxied address in the NetScaler Client IP header */
#define LI_O_INHERITED 0x2000 /* inherited FD from the parent process (fd@) */
#define LI_O_MWORKER 0x4000 /* keep the FD open in the master but close it in the children */
+#define LI_O_NOSTOP 0x8000 /* keep the listener active even after a soft stop */
/* Note: if a listener uses LI_O_UNLIMITED, it is highly recommended that it adds its own
* maxconn setting to the global.maxsock value so that its resources are reserved.
diff --git a/src/proxy.c b/src/proxy.c
index f3208ef..763b95d 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -1110,20 +1110,27 @@
* This function completely stops a proxy and releases its listeners. It has
* to be called when going down in order to release the ports so that another
* process may bind to them. It must also be called on disabled proxies at the
- * end of start-up. When all listeners are closed, the proxy is set to the
+ * end of start-up. If all listeners are closed, the proxy is set to the
* PR_STSTOPPED state.
*/
void stop_proxy(struct proxy *p)
{
struct listener *l;
+ int nostop = 0;
list_for_each_entry(l, &p->conf.listeners, by_fe) {
+ if (l->options & LI_O_NOSTOP) {
+ HA_ATOMIC_ADD(&unstoppable_jobs, 1);
+ nostop = 1;
+ continue;
+ }
unbind_listener(l);
if (l->state >= LI_ASSIGNED) {
delete_listener(l);
}
}
- p->state = PR_STSTOPPED;
+ if (!nostop)
+ p->state = PR_STSTOPPED;
}
/* This function resumes listening on the specified proxy. It scans all of its