Igor Gariev (gariev) wrote in changelog,
Igor Gariev
gariev
changelog

[livejournal] r20255: LJSUP-9747: Update admin tools

Committer: gariev
LJSUP-9747: Update admin tools
Minor bugfixing + more debug info
U   trunk/cgi-bin/LJ/MemCache.pm
Modified: trunk/cgi-bin/LJ/MemCache.pm
===================================================================
--- trunk/cgi-bin/LJ/MemCache.pm	2011-10-07 14:38:44 UTC (rev 20254)
+++ trunk/cgi-bin/LJ/MemCache.pm	2011-10-07 14:42:01 UTC (rev 20255)
@@ -171,6 +171,8 @@
 
 # 'host:port' => handler
 my %connections;
+## 'host:port' => pid
+my %connections_pid;
 
 use vars qw( $GET_DISABLED );
 $GET_DISABLED = 0;
@@ -225,12 +227,19 @@
 sub _connect {
     my ($server) = @_;
 
+    if ($connections{$server} && $connections_pid{$server} ne $$) {
+        warn "Connection to $server was established from other PID: old=$connections_pid{$server}, cur=$$";
+        my $old_handler = delete $connections{$server};
+        $old_handler->disconnect_all;
+    }
+
     unless ( exists $connections{$server} ) {
         init()
             unless defined $used_handler;
 
         $connections{$server}
             = $used_handler->new({ 'servers' => [ $server ] });
+        $connections_pid{$server} = $$;
     }
 
     return $connections{$server};
@@ -318,6 +327,7 @@
     foreach my $conn ( values %connections ) {
         $conn->disconnect_all;
     }
+    %connections = ();
 }
 
 sub list_servers {

Tags: gariev, livejournal, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments