svn commit: r1936637 - spamassassin/trunk/lib/Mail/SpamAssassin/Plugin

[email protected] Mon, 27 Jul 2026 13:49:48 -0000
Newsgroups gmane.mail.spam.spamassassin.cvs
Message-ID <178516018859.3078272.625597774439944520@svn03-he-fi>
Author: gbechis
Date: Mon Jul 27 13:49:48 2026
New Revision: 1936637

Log:
Track the PID that owns each cached dbh/sth set and reconnect whenever
the current process differs

Modified:
   spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DecodeShortURLs.pm
   spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ExtractText.pm
   spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Redirectors.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DecodeShortURLs.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DecodeShortURLs.pm	Mon Jul 27 13:30:04 2026	(r1936636)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DecodeShortURLs.pm	Mon Jul 27 13:49:48 2026	(r1936637)
@@ -506,7 +506,7 @@ sub finish_parsing_start {
 sub initialise_url_shortener_cache {
   my ($self, $conf) = @_;
 
-  return if $self->{dbh};
+  return if $self->{dbh} && $self->{dbh_pid} && $self->{dbh_pid} == $$;
   return if !$conf->{url_shortener_cache_type};
 
   if (!$conf->{url_shortener_cache_dsn}) {
@@ -649,10 +649,13 @@ sub initialise_url_shortener_cache {
   if ($@ || !$self->{sth_clean}) {
     warn "DecodeShortURLs: cache connect failed: $@\n";
     undef $self->{dbh};
+    undef $self->{dbh_pid};
     undef $self->{sth_insert};
     undef $self->{sth_select};
     undef $self->{sth_delete};
     undef $self->{sth_clean};
+  } else {
+    $self->{dbh_pid} = $$;
   }
 }
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ExtractText.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ExtractText.pm	Mon Jul 27 13:30:04 2026	(r1936636)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/ExtractText.pm	Mon Jul 27 13:49:48 2026	(r1936637)
@@ -550,7 +550,7 @@ sub parse_config {
 sub initialise_extracttext_cache {
   my ($self, $conf) = @_;
 
-  return if $self->{dbh};
+  return if $self->{dbh} && $self->{dbh_pid} && $self->{dbh_pid} == $$;
   return if !$conf->{extracttext_cache_type};
 
   if (!$conf->{extracttext_cache_dsn}) {
@@ -691,10 +691,13 @@ sub initialise_extracttext_cache {
   if ($@ || !$self->{sth_clean}) {
     warn "ExtractText: cache connect failed: $@\n";
     undef $self->{dbh};
+    undef $self->{dbh_pid};
     undef $self->{sth_insert};
     undef $self->{sth_select};
     undef $self->{sth_delete};
     undef $self->{sth_clean};
+  } else {
+    $self->{dbh_pid} = $$;
   }
 }
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Redirectors.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Redirectors.pm	Mon Jul 27 13:30:04 2026	(r1936636)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Redirectors.pm	Mon Jul 27 13:49:48 2026	(r1936637)
@@ -674,7 +674,7 @@ like a common browser.
 sub initialise_url_redirector_cache {
   my ($self, $conf) = @_;
 
-  return if $self->{dbh};
+  return if $self->{dbh} && $self->{dbh_pid} && $self->{dbh_pid} == $$;
   return if !$conf->{url_redirector_cache_type};
 
   if (!$conf->{url_redirector_cache_dsn}) {
@@ -817,10 +817,13 @@ sub initialise_url_redirector_cache {
   if ($@ || !$self->{sth_clean}) {
     warn "Redirectors: cache connect failed: $@\n";
     undef $self->{dbh};
+    undef $self->{dbh_pid};
     undef $self->{sth_insert};
     undef $self->{sth_select};
     undef $self->{sth_delete};
     undef $self->{sth_clean};
+  } else {
+    $self->{dbh_pid} = $$;
   }
 }