Skip to content

Instantly share code, notes, and snippets.

/cleanup.diff Secret

Created December 13, 2015 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/cd6dbf0984969cda9559 to your computer and use it in GitHub Desktop.
Save anonymous/cd6dbf0984969cda9559 to your computer and use it in GitHub Desktop.
diff --git a/lib/Mojo/UserAgent.pm b/lib/Mojo/UserAgent.pm
index 8712e3f..cc2b92b 100644
--- a/lib/Mojo/UserAgent.pm
+++ b/lib/Mojo/UserAgent.pm
@@ -293,10 +293,13 @@ sub _remove {
my ($self, $id, $close) = @_;
# Close connection
- my $c = delete $self->{connections}{$id} || {};
- my $tx = $c->{tx};
- return map { $self->_dequeue($_, $id); $self->_loop($_)->remove($id) } 1, 0
- if $close || !$tx || !$tx->keep_alive || $tx->error;
+ my $c = $self->{connections}{$id} || {};
+ my $tx = delete $c->{tx};
+ if ($close || !$tx || !$tx->keep_alive || $tx->error) {
+ delete $self->{connections}{$id};
+ $self->_dequeue($c->{nb}, $id);
+ return $self->_loop($c->{nb})->remove($id);
+ }
# Keep connection alive (CONNECT requests get upgraded)
$self->_enqueue($c->{nb}, join(':', $self->transactor->endpoint($tx)), $id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment