Subject: | [PATCH] CLONE method for multithread/Apache2-worker-MPM support |
version 1.24 fails when loaded under Apache2 multithreaded worker MPM
typical error msg is
No map found matching for GLOB(0xb7896f0) at
/usr/share/perl5/Cache/Memcached.pm line 671.
Problem is that spawning a new ithread changes the memory addresses of
the socket globs, which then messes up %sock_map.
Patch provides a CLONE method to rebuild %sock_map in the new thread.
(...probably also need to do locking around the various get/set methods,
but at least users can do that much themselves...)
Subject: | sockmap.txt |
--- /usr/share/perl5/Cache/Memcached-0-.pm 2007-12-23 12:46:00.000000000 -0800
+++ - 2010-02-11 05:49:17.916491905 -0800
@@ -162,6 +162,14 @@
my %sock_map; # stringified-$sock -> "$ip:$port"
+sub CLONE {
+ # rebuild %sock_map for new thread
+ %sock_map = ();
+ foreach (keys %cache_sock) {
+ $sock_map{$cache_sock{$_}} = $_;
+ }
+}
+
sub _dead_sock {
my ($sock, $ret, $dead_for) = @_;
if (my $ipport = $sock_map{$sock}) {