Skip to content

Commit

Permalink
fixed small file descriptor leak in Mojo::UserAgent
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 28, 2013
1 parent 7af0b1f commit 9d2d8fb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,4 +1,7 @@

3.84 2013-01-29
- Fixed small file descriptor leak in Mojo::UserAgent.

3.83 2013-01-27
- Moved bundled static files to mojo directory.
- Improved documentation.
Expand Down
12 changes: 6 additions & 6 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -99,18 +99,19 @@ sub start {
unless ($self->{nb}) {
croak 'Blocking request in progress' if keys %{$self->{connections}};
warn "-- Switching to non-blocking mode\n" if DEBUG;
$self->_cleanup;
$self->{nb}++;
$self->_cleanup(1);
}
return $self->_start($tx, $cb);
}

# Start blocking
warn "-- Blocking request (@{[$tx->req->url->to_abs]})\n" if DEBUG;
if (delete $self->{nb}) {
if ($self->{nb}) {
croak 'Non-blocking requests in progress' if keys %{$self->{connections}};
warn "-- Switching to blocking mode\n" if DEBUG;
$self->_cleanup(1);
$self->_cleanup;
delete $self->{nb};
}
$self->_start($tx => sub { $tx = pop });

Expand Down Expand Up @@ -159,7 +160,7 @@ sub _cache {
}

sub _cleanup {
my ($self, $restart) = @_;
my $self = shift;
return unless my $loop = $self->_loop;

# Clean up active connections (by closing them)
Expand All @@ -168,9 +169,8 @@ sub _cleanup {
# Clean up keep alive connections
$loop->remove($_->[1]) for @{delete $self->{cache} || []};

# Stop or restart server
# Stop server
delete $self->{server};
$self->_server if $restart;
}

sub _connect {
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -40,7 +40,7 @@ has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };

our $CODENAME = 'Rainbow';
our $VERSION = '3.83';
our $VERSION = '3.84';

sub AUTOLOAD {
my $self = shift;
Expand Down

0 comments on commit 9d2d8fb

Please sign in to comment.