Skip to content

Commit

Permalink
start with 5 threads
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 4, 2014
1 parent 6db3812 commit 8b542f0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/Mojo/IOLoop/Client.pm
Expand Up @@ -11,7 +11,7 @@ use Socket qw(IPPROTO_TCP SO_ERROR TCP_NODELAY);
use constant NDN => $ENV{MOJO_NO_NDN}
? 0
: eval 'use Net::DNS::Native 0.10 (); 1';
my $NDN = NDN ? Net::DNS::Native->new : undef;
my $NDN = NDN ? Net::DNS::Native->new(pool => 5, extra_thread => 1) : undef;

# TLS support requires IO::Socket::SSL
use constant TLS => $ENV{MOJO_NO_TLS}
Expand Down Expand Up @@ -42,12 +42,12 @@ sub connect {
sub { $self->emit(error => 'Connect timeout') });

# Blocking name resolution
$_ && s/[[\]]//g for @$args{qw(address socks_address)};
my $address = $args->{socks_address} || ($args->{address} ||= 'localhost');
return $reactor->next_tick(sub { $self && $self->_connect($args) })
unless NDN && $address ne 'localhost' && !$args->{handle};

# Non-blocking name resolution
$address =~ s/[\[\]]//g;
my $handle = $self->{dns}
= $NDN->getaddrinfo($address, _port($args), {protocol => IPPROTO_TCP});
$reactor->io(
Expand Down Expand Up @@ -85,7 +85,6 @@ sub _connect {
%options = (PeerAddrInfo => $args->{addr_info}) if $args->{addr_info};
$options{Blocking} = 0;
$options{LocalAddr} = $args->{local_address} if $args->{local_address};
$options{PeerAddr} =~ s/[\[\]]//g if $options{PeerAddr};
return $self->emit(error => "Can't connect: $@")
unless $self->{handle} = $handle = IO::Socket::IP->new(%options);
}
Expand Down

0 comments on commit 8b542f0

Please sign in to comment.