Skip to content

Commit

Permalink
improved error handling in Mojo::IOLoop::Client
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 5, 2014
1 parent df0d57f commit 46edc0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,5 +1,6 @@

5.58 2014-11-04
5.58 2014-11-05
- Improved error handling in Mojo::IOLoop::Client.

5.57 2014-11-02
- Deprecated stringification support in Mojo::Collection.
Expand Down
5 changes: 2 additions & 3 deletions lib/Mojo/IOLoop/Client.pm
Expand Up @@ -5,7 +5,7 @@ use Errno 'EINPROGRESS';
use IO::Socket::INET;
use Mojo::IOLoop;
use Scalar::Util 'weaken';
use Socket qw(IPPROTO_TCP SO_ERROR TCP_NODELAY);
use Socket qw(IPPROTO_TCP TCP_NODELAY);

# IPv6 support requires IO::Socket::IP
use constant IPV6 => $ENV{MOJO_NO_IPV6}
Expand Down Expand Up @@ -81,8 +81,7 @@ sub _ready {
my $handle = $self->{handle};
return $! == EINPROGRESS ? undef : $self->emit(error => $!)
if $handle->isa('IO::Socket::IP') && !$handle->connect;
return $self->emit(error => $! = $handle->sockopt(SO_ERROR))
unless $handle->connected;
return $self->emit(error => $! || 'Not connected') unless $handle->connected;

# Disable Nagle's algorithm
setsockopt $handle, IPPROTO_TCP, TCP_NODELAY, 1;
Expand Down

0 comments on commit 46edc0f

Please sign in to comment.