Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
improved resileince of Mojo::IOLoop::Client
  • Loading branch information
kraih committed Feb 12, 2012
1 parent cc6f019 commit af4ba67
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,7 +1,8 @@
This file documents the revision history for Perl extension Mojolicious.

2.49 2012-02-11 00:00:00
2.49 2012-02-12 00:00:00
- Improved version command to be more responsive. (crab)
- Improved resilience of Mojo::IOLoop::Client.
- Improved documentation.
- Fixed parent combinator bug in Mojo::DOM::CSS. (sharifulin, sri)

Expand Down
14 changes: 4 additions & 10 deletions lib/Mojo/IOLoop/Client.pm
Expand Up @@ -23,11 +23,7 @@ has iowatcher => sub {
Mojo::IOLoop->singleton->iowatcher;
};

sub DESTROY {
my $self = shift;
return if $self->{connected};
$self->_cleanup;
}
sub DESTROY { shift->_cleanup }

# "I wonder where Bart is, his dinner's getting all cold... and eaten."
sub connect {
Expand All @@ -42,8 +38,8 @@ sub connect {
sub _cleanup {
my $self = shift;
return unless my $watcher = $self->{iowatcher};
$watcher->drop($self->{timer}) if $self->{timer};
$watcher->drop($self->{handle}) if $self->{handle};
$watcher->drop(delete $self->{timer}) if $self->{timer};
$watcher->drop(delete $self->{handle}) if $self->{handle};
}

sub _connect {
Expand Down Expand Up @@ -91,7 +87,6 @@ sub _connect {
SSL_startHandshake => 0,
SSL_error_trap => sub {
$self->_cleanup;
close delete $self->{handle};
$self->emit_safe(error => $_[1]);
},
SSL_cert_file => $args->{tls_cert},
Expand All @@ -107,7 +102,7 @@ sub _connect {

# Start writing right away
$self->{handle} = $handle;
$watcher->io($handle => sub { $self->_connecting });
$watcher->io($handle => sub { $self->_connecting })->watch($handle, 0, 1);
}

# "Have you ever seen that Blue Man Group? Total ripoff of the Smurfs.
Expand All @@ -130,7 +125,6 @@ sub _connecting {
unless $handle->connected;

# Connected
$self->{connected} = 1;
$self->_cleanup;
$self->emit_safe(connect => $handle);
}
Expand Down

0 comments on commit af4ba67

Please sign in to comment.