Skip to content

Commit

Permalink
fix bug in Mojo::Server::Prefork where the TTOU signal would not alwa…
Browse files Browse the repository at this point in the history
…ys stop a worker
  • Loading branch information
kraih committed Jan 31, 2015
1 parent 134bc00 commit 0d61a23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Changes
Expand Up @@ -6,6 +6,8 @@
- Improved Hypnotoad load balancing by calling srand() after starting a new
worker in Mojo::Server::Prefork.
- Fixed bug in Mojo::IOLoop where the accept limit was applied too broadly.
- Fixed bug in Mojo::Server::Prefork where the TTOU signal would not always
stop a worker.
- Fixed bug in Mojo::DOM::CSS where combinators needed to be surrounded by
whitespace.

Expand Down
8 changes: 4 additions & 4 deletions lib/Mojo/Server/Prefork.pm
Expand Up @@ -4,7 +4,6 @@ use Mojo::Base 'Mojo::Server::Daemon';
use Fcntl ':flock';
use File::Spec::Functions qw(catfile tmpdir);
use IO::Poll qw(POLLIN POLLPRI);
use List::Util 'shuffle';
use Mojo::Util 'steady_time';
use POSIX 'WNOHANG';
use Scalar::Util 'weaken';
Expand Down Expand Up @@ -89,9 +88,10 @@ sub run {
local $SIG{QUIT} = sub { $self->_term(1) };
local $SIG{TTIN} = sub { $self->workers($self->workers + 1) };
local $SIG{TTOU} = sub {
$self->workers($self->workers - 1) if $self->workers > 0;
return unless $self->workers;
$self->{pool}{shuffle keys %{$self->{pool}}}{graceful} ||= steady_time;
$self->workers > 0 ? $self->workers($self->workers - 1) : return;
for my $w (values %{$self->{pool}}) {
($w->{graceful} = steady_time) and last unless $w->{graceful};
}
};

# Preload application before starting workers
Expand Down

0 comments on commit 0d61a23

Please sign in to comment.