Changeset 833 for trunk

Show
Ignore:
Timestamp:
10/21/09 21:51:10 (5 weeks ago)
Author:
bradfitz
Message:

Checking in changes prior to tagging of version 1.28. Changelog diff is:

Index: ChangeLog
===================================================================
--- ChangeLog (revision 832)
+++ ChangeLog (working copy)
@@ -1,4 +1,7 @@
+2009-10-21: version 1.28

+ * IPv6 support (https://rt.cpan.org/Ticket/Display.html?id=50577)
+

  • Add Encode.pm requirement to Makefile.PL for perl 5.6.x (Ask).


2009-09-22: version 1.27

Location:
trunk/api/perl
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/api/perl/ChangeLog

    r829 r833  
     12009-10-21: version 1.28 
     2 
     3        * IPv6 support (https://rt.cpan.org/Ticket/Display.html?id=50577) 
    14 
    25        * Add Encode.pm requirement to Makefile.PL for perl 5.6.x (Ask). 
  • trunk/api/perl/lib/Cache/Memcached.pm

    r827 r833  
    3636use constant COMPRESS_SAVINGS => 0.20; # percent 
    3737 
    38 use vars qw($VERSION $HAVE_ZLIB $FLAG_NOSIGNAL); 
    39 $VERSION = "1.27"; 
     38use vars qw($VERSION $HAVE_ZLIB $FLAG_NOSIGNAL $HAVE_SOCKET6); 
     39$VERSION = "1.28"; 
    4040 
    4141BEGIN { 
    4242    $HAVE_ZLIB = eval "use Compress::Zlib (); 1;"; 
     43    $HAVE_SOCKET6 = eval "use Socket6 qw(AF_INET6 PF_INET6); 1;"; 
    4344} 
    4445 
     
    232233 
    233234    my $now = time(); 
    234     my ($ip, $port) = $host =~ /(.*):(\d+)/; 
     235    my ($ip, $port) = $host =~ /(.*):(\d+)$/; 
     236    $ip =~ s/[\[\]]//g; # get rid of optional IPv6 brackets 
     237 
    235238    return undef if 
    236239        $host_dead{$host} && $host_dead{$host} > $now; 
     
    245248        # if a preferred IP is known, try that first. 
    246249        if ($self && $self->{pref_ip}{$ip}) { 
    247             socket($sock, PF_INET, SOCK_STREAM, $proto); 
    248             $sock_map{$sock} = $host; 
    249250            my $prefip = $self->{pref_ip}{$ip}; 
    250             $sin = Socket::sockaddr_in($port,Socket::inet_aton($prefip)); 
     251            if ($HAVE_SOCKET6 && index($prefip, ':') != -1) { 
     252                no strict 'subs';  # for PF_INET6 and AF_INET6, weirdly imported 
     253                socket($sock, PF_INET6, SOCK_STREAM, $proto); 
     254                $sock_map{$sock} = $host; 
     255                $sin = Socket6::pack_sockaddr_in6($port, 
     256                                                  Socket6::inet_pton(AF_INET6, $prefip)); 
     257            } else { 
     258                socket($sock, PF_INET, SOCK_STREAM, $proto); 
     259                $sock_map{$sock} = $host; 
     260                $sin = Socket::sockaddr_in($port, Socket::inet_aton($prefip)); 
     261            } 
     262 
    251263            if (_connect_sock($sock,$sin,$self->{connect_timeout})) { 
    252264                $connected = 1; 
     
    261273        # normal path, or fallback path if preferred IP failed 
    262274        unless ($connected) { 
    263             socket($sock, PF_INET, SOCK_STREAM, $proto); 
    264             $sock_map{$sock} = $host; 
    265             $sin = Socket::sockaddr_in($port,Socket::inet_aton($ip)); 
     275            if ($HAVE_SOCKET6 && index($ip, ':') != -1) { 
     276                no strict 'subs';  # for PF_INET6 and AF_INET6, weirdly imported 
     277                socket($sock, PF_INET6, SOCK_STREAM, $proto); 
     278                $sock_map{$sock} = $host; 
     279                $sin = Socket6::pack_sockaddr_in6($port, 
     280                                                  Socket6::inet_pton(AF_INET6, $ip)); 
     281            } else { 
     282                socket($sock, PF_INET, SOCK_STREAM, $proto); 
     283                $sock_map{$sock} = $host; 
     284                $sin = Socket::sockaddr_in($port, Socket::inet_aton($ip)); 
     285            } 
     286 
    266287            my $timeout = $self ? $self->{connect_timeout} : 0.25; 
    267             unless (_connect_sock($sock,$sin,$timeout)) { 
     288            unless (_connect_sock($sock, $sin, $timeout)) { 
    268289                my $cb = $self ? $self->{cb_connect_fail} : undef; 
    269290                $cb->($ip) if $cb;