CLEANUP: listeners: remove the do_close argument to unbind_listener()
And also remove it from its callers. This subtle distinction was added as
sort of a hack for the seamless reload feature but is not needed anymore
since the do_close turned unused since commit previous commit ("MEDIUM:
listener: let do_unbind_listener() decide whether to close or not").
This also removes the unbind_listener_no_close() function.
diff --git a/src/listener.c b/src/listener.c
index 5002879..94db957 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -289,7 +289,7 @@
*/
if ((master && !(listener->options & LI_O_MWORKER)) ||
(!master && (listener->options & LI_O_MWORKER))) {
- do_unbind_listener(listener, 1);
+ do_unbind_listener(listener);
}
if (listener->state == LI_LISTEN) {
@@ -299,12 +299,7 @@
/* we don't want to enable this listener and don't
* want any fd event to reach it.
*/
- if (!(global.tune.options & GTUNE_SOCKET_TRANSFER))
- do_unbind_listener(listener, 1);
- else {
- do_unbind_listener(listener, 0);
- listener_set_state(listener, LI_LISTEN);
- }
+ do_unbind_listener(listener);
}
else if (!listener->maxconn || listener->nbconn < listener->maxconn) {
listener->rx.proto->enable(listener);
@@ -329,7 +324,6 @@
void stop_listener(struct listener *l, int lpx, int lpr, int lli)
{
struct proxy *px = l->bind_conf->frontend;
- int must_close;
if (l->options & LI_O_NOSTOP) {
/* master-worker sockpairs are never closed but don't count as a
@@ -338,16 +332,6 @@
return;
}
- /* There are several cases where we must not close an FD:
- * - we're starting up and we have socket transfers enabled;
- * - we're the master and this FD was inherited;
- */
- if ((global.tune.options & GTUNE_SOCKET_TRANSFER && global.mode & MODE_STARTING) ||
- (master && (l->rx.flags & RX_F_INHERITED)))
- must_close = 0;
- else
- must_close = 1;
-
if (!lpx)
HA_SPIN_LOCK(PROXY_LOCK, &px->lock);
@@ -358,7 +342,7 @@
HA_SPIN_LOCK(LISTENER_LOCK, &l->lock);
if (l->state > LI_INIT) {
- do_unbind_listener(l, must_close);
+ do_unbind_listener(l);
if (l->state >= LI_ASSIGNED)
__delete_listener(l);
@@ -556,11 +540,14 @@
}
}
-/* Must be called with the lock held. Depending on <do_close> value, it does
- * what unbind_listener or unbind_listener_no_close should do. It can also
- * close a zombie listener's FD when called in early states.
+/* This function closes the listening socket for the specified listener,
+ * provided that it's already in a listening state. The listener enters the
+ * LI_ASSIGNED state, except if the FD is not closed, in which case it may
+ * remain in LI_LISTEN. Depending on the process' status (master or worker),
+ * the listener's bind options and the receiver's origin, it may or may not
+ * close the receiver's FD. Must be called with the lock held.
*/
-void do_unbind_listener(struct listener *listener, int do_close)
+void do_unbind_listener(struct listener *listener)
{
MT_LIST_DEL(&listener->wait_queue);
@@ -611,23 +598,14 @@
/* This function closes the listening socket for the specified listener,
* provided that it's already in a listening state. The listener enters the
- * LI_ASSIGNED state. This function is intended to be used as a generic
+ * LI_ASSIGNED state, except if the FD is not closed, in which case it may
+ * remain in LI_LISTEN. This function is intended to be used as a generic
* function for standard protocols.
*/
void unbind_listener(struct listener *listener)
{
HA_SPIN_LOCK(LISTENER_LOCK, &listener->lock);
- do_unbind_listener(listener, 1);
- HA_SPIN_UNLOCK(LISTENER_LOCK, &listener->lock);
-}
-
-/* This function pretends the listener is dead, but keeps the FD opened, so
- * that we can provide it, for conf reloading.
- */
-void unbind_listener_no_close(struct listener *listener)
-{
- HA_SPIN_LOCK(LISTENER_LOCK, &listener->lock);
- do_unbind_listener(listener, 0);
+ do_unbind_listener(listener);
HA_SPIN_UNLOCK(LISTENER_LOCK, &listener->lock);
}
diff --git a/src/mworker.c b/src/mworker.c
index 2ef7e7d..f3147a1 100644
--- a/src/mworker.c
+++ b/src/mworker.c
@@ -423,13 +423,7 @@
list_for_each_entry_safe(l, l_next, &curproxy->conf.listeners, by_fe) {
/* remove the listener, but not those we need in the master... */
if (!(l->options & LI_O_MWORKER)) {
- /* unbind the listener but does not close if
- the FD is inherited with fd@ from the parent
- process */
- if (l->rx.flags & RX_F_INHERITED)
- unbind_listener_no_close(l);
- else
- unbind_listener(l);
+ unbind_listener(l);
delete_listener(l);
} else {
listen_in_master = 1;
diff --git a/src/proto_uxst.c b/src/proto_uxst.c
index 4ec672f..250c630 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -185,7 +185,7 @@
/* Listener's lock already held. Call lockless version of
* unbind_listener. */
- do_unbind_listener(l, 1);
+ do_unbind_listener(l);
return 0;
}