BUG/MEDIUM: listener: never suspend inherited sockets

It is not acceptable to suspend an inherited socket because we'd kill
its listening state, making it possibly unrecoverable for future
processes. The situation which can trigger this is when there is an
abns socket in a config and an inherited FD on another listener. Upon
soft reload, the abns fails to bind, a SIGTTOU is sent to the old
process which suspends everything, including the inherited FD, then
the new process can bind and tell the old one to quit. Except that the
new FD was not set back to the listen state, which is detected by
listener_accept() which can pause it. It's only upon second reload
that the FD works again.

The solution is to refrain from suspending such FDs since we don't own
them. And the next process will get them right anyway from its config.
For now only TCP and UDP face this issue so it's better to address this
on a protocol basis

No backport is needed, this is related to the new listeners in 2.3.
This commit is contained in:
Willy Tarreau 2020-11-04 14:14:55 +01:00
parent 38dba27d4d
commit 59b5da4873
2 changed files with 12 additions and 0 deletions

View File

@ -774,6 +774,12 @@ static int tcp_suspend_receiver(struct receiver *rx)
const struct sockaddr sa = { .sa_family = AF_UNSPEC }; const struct sockaddr sa = { .sa_family = AF_UNSPEC };
int ret; int ret;
/* we never do that with a shared FD otherwise we'd break it in the
* parent process and any possible subsequent worker inheriting it.
*/
if (rx->flags & RX_F_INHERITED)
return -1;
if (connect(rx->fd, &sa, sizeof(sa)) < 0) if (connect(rx->fd, &sa, sizeof(sa)) < 0)
goto check_already_done; goto check_already_done;

View File

@ -206,6 +206,12 @@ static int udp_suspend_receiver(struct receiver *rx)
if (rx->fd < 0) if (rx->fd < 0)
return 0; return 0;
/* we never do that with a shared FD otherwise we'd break it in the
* parent process and any possible subsequent worker inheriting it.
*/
if (rx->flags & RX_F_INHERITED)
return -1;
if (getsockname(rx->fd, (struct sockaddr *)&ss, &len) < 0) if (getsockname(rx->fd, (struct sockaddr *)&ss, &len) < 0)
return -1; return -1;