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

[email protected]
Newsgroups gmane.mail.spam.spamassassin.cvs
Message-ID <177308016002.1192625.8489689879641832555@svn02-us-east.apache.org>
Author: gbechis
Date: Mon Mar  9 18:15:59 2026
New Revision: 1932239

Log:
improve locking

Modified:
   spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/NeuralNetwork.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/NeuralNetwork.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/NeuralNetwork.pm	Mon Mar  9 17:02:09 2026	(r1932238)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/NeuralNetwork.pm	Mon Mar  9 18:15:59 2026	(r1932239)
@@ -627,6 +627,26 @@ sub learn_message {
     return;
   };
 
+  # Always reload model from disk after acquiring the lock so we train on the
+  # latest state saved by any other spamd child.
+  if (-f $dataset_path) {
+    eval {
+      $self->{neural_model} = AI::FANN->new_from_file($dataset_path);
+      $self->{_neural_model_load_time} = time();
+      1;
+    } or do {
+      dbg("Failed to reload model after lock: " . ($@ || 'unknown'));
+    };
+  } else {
+    undef $self->{neural_model};
+  }
+  # Invalidate vocabulary cache
+  if (defined $self->{_vocab_cache}) {
+    my $username = $self->{main}->{username};
+    delete $self->{_vocab_cache}{$username};
+    delete $self->{_vocab_cache_time}{$username};
+  }
+
   # Update the vocabulary
   my $update_vocab = 1;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.