Skip to content

Commit

Permalink
attempt to use _nb in _remove
Browse files Browse the repository at this point in the history
  • Loading branch information
jberger committed Dec 13, 2015
1 parent 6e960e1 commit 186d949
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -274,7 +274,7 @@ sub _finish {

sub _loop { $_[1] ? Mojo::IOLoop->singleton : $_[0]->ioloop }

sub _nb { $_[1]->ioloop == Mojo::IOLoop->singleton }
sub _nb { $_[1] ? ($_[1]->ioloop == Mojo::IOLoop->singleton) : undef }

sub _read {
my ($self, $id, $chunk) = @_;
Expand All @@ -301,13 +301,15 @@ sub _remove {
my ($self, $id, $close) = @_;

# Close connection
my $c = delete $self->{connections}{$id} || {};
my $tx = $c->{tx};
my $c = delete $self->{connections}{$id};
my $tx = $c ? $c->tx : undef;
return map { $self->_dequeue($_, $id); $self->_loop($_)->remove($id) } 1, 0
if $close || !$tx || !$tx->keep_alive || $tx->error;

# Keep connection alive (CONNECT requests get upgraded)
$self->_enqueue($c->{nb}, join(':', $self->transactor->endpoint($tx)), $id)
my $nb = $c->{nb};
# my $nb = $self->_nb($c);
$self->_enqueue($nb, join(':', $self->transactor->endpoint($tx)), $id)
unless uc $tx->req->method eq 'CONNECT';
}

Expand Down

0 comments on commit 186d949

Please sign in to comment.