Mercurial > hg > nginx-tests
changeset 1752:ba6e24e38f03
Tests: improved stop_daemons() to send signal again.
As was observed, it's possible that a signal to complete a uwsgi daemon
can be ignored while it is starting up, which results in tests hang due
to eternal waiting on child processes termination. Notably, it is seen
when running tests with a high number of prove jobs on a low-profile VM
against nginx with broken modules and/or configuration. To reproduce:
$ TEST_NGINX_GLOBALS=ERROR prove -j16 uwsgi*.t
Inspecting uwsgi under ktrace on FreeBSD confirms that a SIGTERM signal
is ignored at the very beginning of uwsgi startup. It is then replaced
with a default action after listen(), thus waiting until uwsgi is ready
to accept new TCP connections doesn't completely solve the hang window.
The fix is to retry sending a signal some time after waitpid(WNOHANG)
continuously demonstrated no progress with reaping a signaled process.
It is modelled after f13ead27f89c that improved stop() for nginx.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 29 Dec 2021 22:29:23 +0300 |
parents | 18ac4d9e5a2a |
children | 0c50a00e6733 |
files | lib/Test/Nginx.pm |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/Test/Nginx.pm Thu Dec 09 17:36:29 2021 +0000 +++ b/lib/Test/Nginx.pm Wed Dec 29 22:29:23 2021 +0300 @@ -554,7 +554,19 @@ while ($self->{_daemons} && scalar @{$self->{_daemons}}) { my $p = shift @{$self->{_daemons}}; kill $^O eq 'MSWin32' ? 9 : 'TERM', $p; - waitpid($p, 0); + + my $exited; + + for (1 .. 50) { + $exited = waitpid($p, WNOHANG) != 0; + last if $exited; + select undef, undef, undef, 0.1; + } + + if (!$exited) { + kill $^O eq 'MSWin32' ? 9 : 'TERM', $p; + waitpid($p, 0); + } } return $self;