Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
improved Mojo::IOLoop::Client to use a timeout for every connection
  • Loading branch information
kraih committed Aug 16, 2014
1 parent 94d484c commit 63ed603
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,5 +1,6 @@

5.30 2014-08-17
5.30 2014-08-16
- Improved Mojo::IOLoop::Client to use a timeout for every connection.

5.29 2014-08-16
- Added helpers method to Mojolicious::Controller.
Expand Down
8 changes: 4 additions & 4 deletions lib/Mojo/IOLoop/Client.pm
Expand Up @@ -62,13 +62,13 @@ sub _connect {
my $class = IPV6 ? 'IO::Socket::IP' : 'IO::Socket::INET';
return $self->emit(error => "Couldn't connect: $@")
unless $self->{handle} = $handle = $class->new(%options);

# Timeout
$self->{timer} = $reactor->timer($args->{timeout} || 10,
sub { $self->emit(error => 'Connect timeout') });
}
$handle->blocking(0);

# Timeout
$self->{timer} = $reactor->timer($args->{timeout} || 10,
sub { $self->emit(error => 'Connect timeout') });

# Wait for handle to become writable
weaken $self;
$reactor->io($handle => sub { $self->_ready($args) })->watch($handle, 0, 1);
Expand Down

0 comments on commit 63ed603

Please sign in to comment.