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.
This commit is contained in:
Willy Tarreau 2020-10-09 15:55:23 +02:00
parent 374e9af358
commit 75c98d166e
4 changed files with 24 additions and 52 deletions

View File

@ -71,23 +71,23 @@ void dequeue_all_listeners();
/* Dequeues all listeners waiting for a resource in proxy <px>'s queue */
void dequeue_proxy_listeners(struct proxy *px);
/* Must be called with the lock held. Depending on <do_close> value, it does
* what unbind_listener or unbind_listener_no_close should do.
/* 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);
/* 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);
/* 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);
/* creates one or multiple listeners for bind_conf <bc> on sockaddr <ss> on port
* range <portl> to <porth>, and possibly attached to fd <fd> (or -1 for auto
* allocation). The address family is taken from ss->ss_family, and the protocol

View File

@ -289,7 +289,7 @@ void enable_listener(struct listener *listener)
*/
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 @@ void enable_listener(struct listener *listener)
/* 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 enable_listener(struct listener *listener)
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 @@ void stop_listener(struct listener *l, int lpx, int lpr, int lli)
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 @@ void stop_listener(struct listener *l, int lpx, int lpr, int lli)
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 @@ void dequeue_proxy_listeners(struct proxy *px)
}
}
/* 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 @@ void do_unbind_listener(struct listener *listener, int do_close)
/* 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);
}

View File

@ -423,13 +423,7 @@ void mworker_cleanlisteners()
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;

View File

@ -185,7 +185,7 @@ static int uxst_suspend_receiver(struct receiver *rx)
/* Listener's lock already held. Call lockless version of
* unbind_listener. */
do_unbind_listener(l, 1);
do_unbind_listener(l);
return 0;
}