[MEDIUM] perform a soft stop when pause fails to be nice with non-Linux systems.
At least OpenBSD and Solaris do not support shutdown() on listening socket. So instead of blocking the hot reconfiguration, at least we can perform a soft stop if the shutdown fails, so that the new daemon can bind to the ports without trouble.
This commit is contained in:
parent
1a71cc14c9
commit
007aa4606e
19
haproxy.c
19
haproxy.c
|
@ -6753,11 +6753,12 @@ static void soft_stop(void) {
|
||||||
static void pause_proxy(struct proxy *p) {
|
static void pause_proxy(struct proxy *p) {
|
||||||
struct listener *l;
|
struct listener *l;
|
||||||
for (l = p->listen; l != NULL; l = l->next) {
|
for (l = p->listen; l != NULL; l = l->next) {
|
||||||
shutdown(l->fd, SHUT_RD);
|
if (shutdown(l->fd, SHUT_RD) == 0) {
|
||||||
FD_CLR(l->fd, StaticReadEvent);
|
FD_CLR(l->fd, StaticReadEvent);
|
||||||
p->state = PR_STPAUSED;
|
p->state = PR_STPAUSED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function temporarily disables listening so that another new instance
|
* This function temporarily disables listening so that another new instance
|
||||||
|
@ -6766,8 +6767,10 @@ static void pause_proxy(struct proxy *p) {
|
||||||
* the proxy, or a SIGTTIN can be sent to listen again.
|
* the proxy, or a SIGTTIN can be sent to listen again.
|
||||||
*/
|
*/
|
||||||
static void pause_proxies(void) {
|
static void pause_proxies(void) {
|
||||||
|
int err;
|
||||||
struct proxy *p;
|
struct proxy *p;
|
||||||
|
|
||||||
|
err = 0;
|
||||||
p = proxy;
|
p = proxy;
|
||||||
tv_now(&now); /* else, the old time before select will be used */
|
tv_now(&now); /* else, the old time before select will be used */
|
||||||
while (p) {
|
while (p) {
|
||||||
|
@ -6775,9 +6778,19 @@ static void pause_proxies(void) {
|
||||||
Warning("Pausing proxy %s.\n", p->id);
|
Warning("Pausing proxy %s.\n", p->id);
|
||||||
send_log(p, LOG_WARNING, "Pausing proxy %s.\n", p->id);
|
send_log(p, LOG_WARNING, "Pausing proxy %s.\n", p->id);
|
||||||
pause_proxy(p);
|
pause_proxy(p);
|
||||||
|
if (p->state != PR_STPAUSED) {
|
||||||
|
err |= 1;
|
||||||
|
Warning("Proxy %s failed to enter pause mode.\n", p->id);
|
||||||
|
send_log(p, LOG_WARNING, "Proxy %s failed to enter pause mode.\n", p->id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
|
if (err) {
|
||||||
|
Warning("Some proxies refused to pause, performing soft stop now.\n");
|
||||||
|
send_log(p, LOG_WARNING, "Some proxies refused to pause, performing soft stop now.\n");
|
||||||
|
soft_stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9259,6 +9272,10 @@ int main(int argc, char **argv) {
|
||||||
if (nb_oldpids == 0)
|
if (nb_oldpids == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* FIXME-20060514: Solaris and OpenBSD do not support shutdown() on
|
||||||
|
* listening sockets. So on those platforms, it would be wiser to
|
||||||
|
* simply send SIGUSR1, which will not be undoable.
|
||||||
|
*/
|
||||||
tell_old_pids(SIGTTOU);
|
tell_old_pids(SIGTTOU);
|
||||||
/* give some time to old processes to stop listening */
|
/* give some time to old processes to stop listening */
|
||||||
w.tv_sec = 0;
|
w.tv_sec = 0;
|
||||||
|
|
Loading…
Reference in New Issue