Skip to content

Commit

Permalink
use a little less code
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 13, 2017
1 parent a5ce008 commit fcb9107
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
3 changes: 1 addition & 2 deletions lib/Mojo/IOLoop/Client.pm
Expand Up @@ -154,8 +154,7 @@ sub _try_tls {

# Start TLS handshake
weaken $self;
my $tls = $self->{tls} = Mojo::IOLoop::TLS->new(reactor => $reactor);
weaken $tls->{reactor};
my $tls = Mojo::IOLoop::TLS->new(reactor => $reactor);
$tls->on(finish => sub { $self->_cleanup->emit(connect => pop) });
$tls->on(error => sub { $self->emit(error => pop) });
$tls->negotiate(%$args, handle => $handle);
Expand Down
14 changes: 3 additions & 11 deletions lib/Mojo/IOLoop/Server.pm
Expand Up @@ -95,17 +95,9 @@ sub _accept {
$self->emit(accept => $handle) and next unless my $args = $self->{args};

# Start TLS handshake
my $tls = $self->{handles}{my $id = "$handle"}
= Mojo::IOLoop::TLS->new(reactor => $self->reactor);
weaken $tls->{reactor};
$tls->on(
finish => sub {
my $handle = pop;
delete $self->{handles}{$id};
$self->emit(accept => $handle);
}
);
$tls->on(error => sub { delete $self->{handles}{$id} });
my $tls = Mojo::IOLoop::TLS->new(reactor => $self->reactor);
$tls->on(finish => sub { $self->emit(accept => pop) });
$tls->on(error => sub { });
$tls->negotiate(%$args, handle => $handle, server => 1);
}
}
Expand Down
2 changes: 0 additions & 2 deletions lib/Mojo/IOLoop/TLS.pm
Expand Up @@ -3,7 +3,6 @@ use Mojo::Base 'Mojo::EventEmitter';

use Exporter 'import';
use Mojo::File 'path';
use Scalar::Util 'weaken';

# TLS support requires IO::Socket::SSL
use constant HAS_TLS => $ENV{MOJO_NO_TLS}
Expand Down Expand Up @@ -33,7 +32,6 @@ sub negotiate {
return $self->emit(error => 'IO::Socket::SSL 1.94+ required for TLS support')
unless HAS_TLS;

weaken $self;
my $tls = {
SSL_ca_file => $args->{tls_ca}
&& -T $args->{tls_ca} ? $args->{tls_ca} : undef,
Expand Down

0 comments on commit fcb9107

Please sign in to comment.