void maintain_proxies(int *next);
void soft_stop(void);
void pause_proxy(struct proxy *p);
+void stop_proxy(struct proxy *p);
void pause_proxies(void);
void listen_proxies(void);
struct listener *listener;
if (curproxy->state == PR_STSTOPPED) {
+ /* ensure we don't keep listeners uselessly bound */
+ stop_proxy(curproxy);
curproxy = curproxy->next;
continue;
}
if (t == 0) {
Warning("Proxy %s stopped.\n", p->id);
send_log(p, LOG_WARNING, "Proxy %s stopped.\n", p->id);
-
- for (l = p->listen; l != NULL; l = l->next) {
- unbind_listener(l);
- if (l->state >= LI_ASSIGNED) {
- delete_listener(l);
- listeners--;
- }
- }
- p->state = PR_STSTOPPED;
+ stop_proxy(p);
/* try to free more memory */
pool_gc2();
}
}
}
+
+/*
+ * 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
+ * PR_STSTOPPED state.
+ */
+void stop_proxy(struct proxy *p)
+{
+ struct listener *l;
+
+ for (l = p->listen; l != NULL; l = l->next) {
+ unbind_listener(l);
+ if (l->state >= LI_ASSIGNED) {
+ delete_listener(l);
+ listeners--;
+ }
+ }
+ p->state = PR_STSTOPPED;
+}
+
/*
* This function temporarily disables listening so that another new instance
* can start listening. It is designed to be called upon reception of a