r59609 - in /branches/upstream/libcache-memcached-perl/current: ChangeLog META.yml lib/Cache/Memcached.pm

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Sun Jun 20 13:46:47 UTC 2010


Author: gregoa
Date: Sun Jun 20 13:45:23 2010
New Revision: 59609

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=59609
Log:
[svn-upgrade] new version libcache-memcached-perl (1.29)

Modified:
    branches/upstream/libcache-memcached-perl/current/ChangeLog
    branches/upstream/libcache-memcached-perl/current/META.yml
    branches/upstream/libcache-memcached-perl/current/lib/Cache/Memcached.pm

Modified: branches/upstream/libcache-memcached-perl/current/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcache-memcached-perl/current/ChangeLog?rev=59609&op=diff
==============================================================================
--- branches/upstream/libcache-memcached-perl/current/ChangeLog (original)
+++ branches/upstream/libcache-memcached-perl/current/ChangeLog Sun Jun 20 13:45:23 2010
@@ -1,3 +1,12 @@
+2010-06-17: version 1.29
+
+    * fix warnings spew if calling stats on a down server
+
+    * fix buck2sock confusion (Eddie Canales)
+
+	* quell ipv6-related warning
+	  https://rt.cpan.org/Ticket/Display.html?id=51761
+	
 2009-10-21: version 1.28
 
 	* IPv6 support (https://rt.cpan.org/Ticket/Display.html?id=50577)

Modified: branches/upstream/libcache-memcached-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcache-memcached-perl/current/META.yml?rev=59609&op=diff
==============================================================================
--- branches/upstream/libcache-memcached-perl/current/META.yml (original)
+++ branches/upstream/libcache-memcached-perl/current/META.yml Sun Jun 20 13:45:23 2010
@@ -1,17 +1,25 @@
 --- #YAML:1.0
-name:                Cache-Memcached
-version:             1.28
-abstract:            client library for memcached (memory cache daemon)
-license:             ~
-author:              
+name:               Cache-Memcached
+version:            1.29
+abstract:           client library for memcached (memory cache daemon)
+author:
     - Brad Fitzpatrick <brad at danga.com>
-generated_by:        ExtUtils::MakeMaker version 6.42
-distribution_type:   module
-requires:     
-    Encode:                        0
-    Storable:                      0
-    String::CRC32:                 0
-    Time::HiRes:                   0
+license:            unknown
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+build_requires:
+    ExtUtils::MakeMaker:  0
+requires:
+    Encode:         0
+    Storable:       0
+    String::CRC32:  0
+    Time::HiRes:    0
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.55_02
 meta-spec:
-    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
-    version: 1.3
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Modified: branches/upstream/libcache-memcached-perl/current/lib/Cache/Memcached.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcache-memcached-perl/current/lib/Cache/Memcached.pm?rev=59609&op=diff
==============================================================================
--- branches/upstream/libcache-memcached-perl/current/lib/Cache/Memcached.pm (original)
+++ branches/upstream/libcache-memcached-perl/current/lib/Cache/Memcached.pm Sun Jun 20 13:45:23 2010
@@ -1,4 +1,4 @@
-# $Id: Memcached.pm 833 2009-10-21 21:51:10Z bradfitz $
+# $Id: Memcached.pm 844 2010-06-18 01:26:15Z dormando $
 #
 # Copyright (c) 2003, 2004  Brad Fitzpatrick <brad at danga.com>
 #
@@ -26,6 +26,7 @@
     bucketcount _single_sock _stime
     connect_timeout cb_connect_fail
     parser_class
+    buck2sock
 };
 
 # flag definitions
@@ -36,7 +37,7 @@
 use constant COMPRESS_SAVINGS => 0.20; # percent
 
 use vars qw($VERSION $HAVE_ZLIB $FLAG_NOSIGNAL $HAVE_SOCKET6);
-$VERSION = "1.28";
+$VERSION = "1.29";
 
 BEGIN {
     $HAVE_ZLIB = eval "use Compress::Zlib (); 1;";
@@ -56,7 +57,6 @@
 
 my %host_dead;   # host -> unixtime marked dead until
 my %cache_sock;  # host -> socket
-my @buck2sock;   # bucket number -> $sock
 
 my $PROTO_TCP;
 
@@ -68,6 +68,7 @@
 
     my $args = (@_ == 1) ? shift : { @_ };  # hashref-ify args
 
+    $self->{'buck2sock'}= [];
     $self->set_servers($args->{'servers'});
     $self->{'debug'} = $args->{'debug'} || 0;
     $self->{'no_rehash'} = $args->{'no_rehash'};
@@ -101,7 +102,7 @@
     $self->{'buckets'} = undef;
     $self->{'bucketcount'} = 0;
     $self->init_buckets;
-    @buck2sock = ();
+    $self->{'buck2sock'}= [];
 
     $self->{'_single_sock'} = undef;
     if (@{$self->{'servers'}} == 1) {
@@ -152,8 +153,9 @@
 }
 
 sub forget_dead_hosts {
+    my Cache::Memcached $self = shift;
     %host_dead = ();
-    @buck2sock = ();
+    $self->{'buck2sock'} = [];
 }
 
 sub set_stat_callback {
@@ -165,7 +167,7 @@
 my %sock_map;  # stringified-$sock -> "$ip:$port"
 
 sub _dead_sock {
-    my ($sock, $ret, $dead_for) = @_;
+    my ($self, $sock, $ret, $dead_for) = @_;
     if (my $ipport = $sock_map{$sock}) {
         my $now = time();
         $host_dead{$ipport} = $now + $dead_for
@@ -173,18 +175,18 @@
         delete $cache_sock{$ipport};
         delete $sock_map{$sock};
     }
-    @buck2sock = ();
+    $self->{'buck2sock'} = [] if $self;
     return $ret;  # 0 or undef, probably, depending on what caller wants
 }
 
 sub _close_sock {
-    my ($sock) = @_;
+    my ($self, $sock) = @_;
     if (my $ipport = $sock_map{$sock}) {
         close $sock;
         delete $cache_sock{$ipport};
         delete $sock_map{$sock};
     }
-    @buck2sock = ();
+    $self->{'buck2sock'} = [];
 }
 
 sub _connect_sock { # sock, sin, timeout
@@ -226,14 +228,16 @@
     return $ret;
 }
 
-sub sock_to_host { # (host)
+sub sock_to_host { # (host)  #why is this public? I wouldn't have to worry about undef $self if it weren't.
     my Cache::Memcached $self = ref $_[0] ? shift : undef;
     my $host = $_[0];
     return $cache_sock{$host} if $cache_sock{$host};
 
     my $now = time();
     my ($ip, $port) = $host =~ /(.*):(\d+)$/;
-    $ip =~ s/[\[\]]//g; # get rid of optional IPv6 brackets
+    if (defined($ip)) {
+        $ip =~ s/[\[\]]//g;  # get rid of optional IPv6 brackets
+    }
 
     return undef if
         $host_dead{$host} && $host_dead{$host} > $now;
@@ -288,7 +292,7 @@
             unless (_connect_sock($sock, $sin, $timeout)) {
                 my $cb = $self ? $self->{cb_connect_fail} : undef;
                 $cb->($ip) if $cb;
-                return _dead_sock($sock, undef, 20 + int(rand(10)));
+                return _dead_sock($self, $sock, undef, 20 + int(rand(10)));
             }
         }
     } else { # it's a unix domain/local socket
@@ -299,7 +303,7 @@
         unless (_connect_sock($sock,$sin,$timeout)) {
             my $cb = $self ? $self->{cb_connect_fail} : undef;
             $cb->($host) if $cb;
-            return _dead_sock($sock, undef, 20 + int(rand(10)));
+            return _dead_sock($self, $sock, undef, 20 + int(rand(10)));
         }
     }
 
@@ -347,12 +351,13 @@
 }
 
 sub disconnect_all {
+    my Cache::Memcached $self = shift;
     my $sock;
     foreach $sock (values %cache_sock) {
         close $sock;
     }
     %cache_sock = ();
-    @buck2sock = ();
+    $self->{'buck2sock'} = [];
 }
 
 # writes a line, then reads result.  by default stops reading after a
@@ -396,7 +401,7 @@
             next
                 if not defined $res and $!==EWOULDBLOCK;
             unless ($res > 0) {
-                _close_sock($sock);
+                $self->_close_sock($sock);
                 return undef;
             }
             if ($res == length($line)) { # all sent
@@ -411,7 +416,7 @@
             next
                 if !defined($res) and $!==EWOULDBLOCK;
             if ($res == 0) { # catches 0=conn closed or undef=error
-                _close_sock($sock);
+                $self->_close_sock($sock);
                 return undef;
             }
             $offset += $res;
@@ -420,7 +425,7 @@
     }
 
     unless ($state == 2) {
-        _dead_sock($sock); # improperly finished
+        $self->_dead_sock($sock); # improperly finished
         return undef;
     }
 
@@ -614,9 +619,9 @@
                 #    and last;
 
                 # but this variant doesn't crash:
-                $sock = $buck2sock[$bucket] || $self->sock_to_host($self->{buckets}[ $bucket ]);
+                $sock = $self->{'buck2sock'}->[$bucket] || $self->sock_to_host($self->{buckets}[ $bucket ]);
                 if ($sock) {
-                    $buck2sock[$bucket] = $sock;
+                    $self->{'buck2sock'}->[$bucket] = $sock;
                     last;
                 }
 
@@ -676,7 +681,7 @@
         }
 
         close $sock;
-        _dead_sock($sock);
+        $self->_dead_sock($sock);
     };
 
     # $finalize->($key, $flags)
@@ -884,6 +889,7 @@
     my @hosts = @{$self->{'buckets'}};
   HOST: foreach my $host (@hosts) {
         my $sock = $self->sock_to_host($host);
+        next HOST unless $sock;
       TYPE: foreach my $typename (grep !/^self$/, @$types) {
             my $type = $typename eq 'misc' ? "" : " $typename";
             my $lines = _write_and_read($self, $sock, "stats$type\r\n", sub {
@@ -891,7 +897,7 @@
                 return $$bref =~ /^(?:END|ERROR)\r?\n/m;
             });
             unless ($lines) {
-                _dead_sock($sock);
+                $self->_dead_sock($sock);
                 next HOST;
             }
 
@@ -936,9 +942,10 @@
 
   HOST: foreach my $host (@{$self->{'buckets'}}) {
         my $sock = $self->sock_to_host($host);
+        next HOST unless $sock;
         my $ok = _write_and_read($self, $sock, "stats reset");
         unless (defined $ok && $ok eq "RESET\r\n") {
-            _dead_sock($sock);
+            $self->_dead_sock($sock);
         }
     }
     return 1;




More information about the Pkg-perl-cvs-commits mailing list