Skip to content

Commit

Permalink
clean up connections more carefully
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 27, 2016
1 parent 86d410c commit 1baed1c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/Mojo/IOLoop/Subprocess.pm
Expand Up @@ -35,8 +35,10 @@ sub run {
$self->ioloop->stream($stream);
my $buffer;
$stream->on(read => sub { $buffer .= pop });
my $parent = $$;
$stream->on(
close => sub {
return unless $$ == $parent;
waitpid $self->{pid}, 0;
return $self->$second("Non-zero exit status (@{[$? >> 8]})") if $?;
my $result = eval { $self->deserialize->($buffer) } || [];
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/Server/Daemon.pm
Expand Up @@ -21,9 +21,8 @@ has max_requests => 100;
sub DESTROY {
return if Mojo::Util::_global_destruction();
my $self = shift;
$self->_remove($_) for keys %{$self->{connections} || {}};
my $loop = $self->ioloop;
$loop->remove($_) for @{$self->acceptors};
$loop->remove($_) for keys %{$self->{connections} || {}}, @{$self->acceptors};
}

sub run {
Expand Down

0 comments on commit 1baed1c

Please sign in to comment.