Skip to content

Commit

Permalink
small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 12, 2014
1 parent 9221c12 commit deaa1be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -48,10 +48,7 @@ sub start {
my ($self, $tx, $cb) = @_;

# Fork safety
unless (($self->{pid} //= $$) eq $$) {
delete $self->_cleanup->{pid};
$self->server->restart;
}
$self->_cleanup->server->restart unless ($self->{pid} //= $$) eq $$;

# Non-blocking
if ($cb) {
Expand All @@ -78,6 +75,7 @@ sub _cleanup {
return unless my $loop = $self->_loop(0);

# Clean up active connections (by closing them)
delete $self->{pid};
$self->_handle($_, 1) for keys %{$self->{connections} || {}};

# Clean up keep-alive connections
Expand Down
6 changes: 3 additions & 3 deletions lib/Mojo/UserAgent/Server.pm
Expand Up @@ -111,8 +111,8 @@ global default.
my $url = $ua->nb_url('http');
my $url = $ua->nb_url('https');
Get absolute L<Mojo::URL> object for performing non-blocking requests with
L</"app"> and switch protocol if necessary.
Get absolute L<Mojo::URL> object for server processing non-blocking requests
with L</"app"> and switch protocol if necessary.
=head2 restart
Expand All @@ -126,7 +126,7 @@ Restart server with new port.
my $url = $ua->url('http');
my $url = $ua->url('https');
Get absolute L<Mojo::URL> object for performing blocking requests with
Get absolute L<Mojo::URL> object for server processing blocking requests with
L</"app"> and switch protocol if necessary.
=head1 SEE ALSO
Expand Down

0 comments on commit deaa1be

Please sign in to comment.