Skip Menu |

This queue is for tickets about the Cache-Memcached CPAN distribution.

Report information
The Basics
Id: 27181
Status: resolved
Priority: 0/
Queue: Cache-Memcached

People
Owner: Nobody in particular
Requestors: rhesa [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.21
Fixed in: (no value)



Subject: lost connection handling broken due to wrong %sock_map indexing
Cache::Memcached 1.21 doesn't ever attempt to re-connect, and keeps trying to use stale sockets. This is an issue in long-lived processes, because the package variables %sock_map and %cache_sock don't ever get refreshed. The use of %sock_map is broken due to the fact that $sock stringifies differently than \$sock: # Stringified sock $sock: GLOB(0x504290) # Stringified ref to sock \$sock: REF(0x505030) Since you store new sockets with $sock_map{$sock} = $host;, but retrieve them with $sock_map{\$sock}, you never get back the correct $ipport string. This prevents the _dead_sock() and _close_sock() routines from functioning as intended. Observed on Perl 5.8.8. The patch below fixes this issue. Rhesa --- lib/Cache/Memcached_orig.pm 2007-05-17 20:48:32.578814506 +0200 +++ lib/Cache/Memcached.pm 2007-05-17 23:44:30.912864044 +0200 @@ -162,12 +162,12 @@ my %sock_map; # scalaraddr -> "$ip:$por sub _dead_sock { my ($sock, $ret, $dead_for) = @_; - if (my $ipport = $sock_map{\$sock}) { + if (my $ipport = $sock_map{$sock}) { my $now = time(); $host_dead{$ipport} = $now + $dead_for if $dead_for; delete $cache_sock{$ipport}; - delete $sock_map{\$sock}; + delete $sock_map{$sock}; } @buck2sock = (); return $ret; # 0 or undef, probably, depending on what caller wants @@ -175,10 +175,10 @@ sub _dead_sock { sub _close_sock { my ($sock) = @_; - if (my $ipport = $sock_map{\$sock}) { + if (my $ipport = $sock_map{$sock}) { close $sock; delete $cache_sock{$ipport}; - delete $sock_map{\$sock}; + delete $sock_map{$sock}; } @buck2sock = (); }
From: BRADFITZ [...] cpan.org
Confirmed.
fixed in 1.22. And holy shit is rt.cpan.org slow... please, stop filing bugs with this. It took 20x more time to confirm/take/resolve this bug in RT than it did to actually commit the fix to svn and run "shipit" to get a new release out.