]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: listeners: support unstoppable listener
authorWilliam Lallemand <wlallemand@haproxy.com>
Fri, 16 Nov 2018 15:57:21 +0000 (16:57 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 16 Nov 2018 16:05:40 +0000 (17:05 +0100)
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.

include/types/listener.h
src/proxy.c

index 50f1936842094b42f5178781f8ea11183e4fe7a0..eac2037f43c8639f5e68c6aa1222afe8416c7d43 100644 (file)
@@ -101,6 +101,7 @@ enum li_state {
 #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.
index f3208ef205feed346724727f08f6a7699ad53677..763b95de3c6d6a0213d880942e0051e22227f17f 100644 (file)
@@ -1110,20 +1110,27 @@ void zombify_proxy(struct proxy *p)
  * 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