Skip to content

Commit

Permalink
handle sockets a little more efficiently
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 15, 2015
1 parent e3c6e0c commit 3c42bad
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/Mojo/IOLoop/Client.pm
Expand Up @@ -98,11 +98,10 @@ sub _ready {
my $handle = $self->{handle};

# Socket changes in between attempts and needs to be re-added for epoll/kqueue
if ($handle->isa('IO::Socket::IP')) {
if ($handle->isa('IO::Socket::IP') && !$handle->connect) {
return $self->emit(error => $!) unless $! == EINPROGRESS;
$self->reactor->remove($handle);
my ($res, $err) = ($handle->connect, $!);
$self->_wait($handle, $args);
return $err == EINPROGRESS ? undef : $self->emit(error => $err) unless $res;
return $self->_wait($handle, $args);
}

return $self->emit(error => $! || 'Not connected') unless $handle->connected;
Expand Down

0 comments on commit 3c42bad

Please sign in to comment.