You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2004/04/08 18:15:01 UTC

svn commit: rev 9940 - in incubator/spamassassin/trunk/lib/Mail/SpamAssassin: . BayesStore

Author: felicity
Date: Thu Apr  8 09:14:57 2004
New Revision: 9940

Modified:
   incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm
   incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Locker.pm
   incubator/spamassassin/trunk/lib/Mail/SpamAssassin/UnixLocker.pm
   incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Win32Locker.pm
Log:
bug 3251: for things like sa-learn, the bayes db gets locked, then a bunch of learning occurs, then the db is unlocked.  however, if the learning takes more than 600 seconds (10 mins), another process would see the lock as stale and break it, even though the original process is still going.  now, everytime a lock is requested (which is still per message), the lock file will be 'refreshed' via utime().

Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm	(original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm	Thu Apr  8 09:14:57 2004
@@ -180,11 +180,16 @@
     return 0;
   }
 
-  # return if we've already tied to the db's, using the same mode
-  # (locked/unlocked) as before.
-  return 1 if ($self->{already_tied} && $self->{is_locked} == 1);
-
+  # Useful shortcut ...
   my $main = $self->{bayes}->{main};
+
+  # if we've already tied the db's using the same mode
+  # (locked/unlocked) as we want now, freshen the lock and return.
+  if ($self->{already_tied} && $self->{is_locked} == 1) {
+    $main->{locker}->refresh_lock ($self->{locked_file});
+    return 1;
+  }
+
   if (!defined($main->{conf}->{bayes_path})) {
     dbg ("bayes_path not defined");
     return 0;

Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Locker.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Locker.pm	(original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Locker.pm	Thu Apr  8 09:14:57 2004
@@ -55,4 +55,11 @@
 
 ###########################################################################
 
+sub refresh_lock {
+  my ($self, $path) = @_;
+  die "refresh_lock not implemented by Locker subclass";
+}
+
+###########################################################################
+
 1;

Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/UnixLocker.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/UnixLocker.pm	(original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/UnixLocker.pm	Thu Apr  8 09:14:57 2004
@@ -116,6 +116,18 @@
 
 ###########################################################################
 
+sub refresh_lock {
+  my($self, $path) = @_;
+
+  # this could arguably read the lock and make sure the same process
+  # owns it, but this shouldn't, in theory, be an issue.
+  utime time, time, "$path.lock";
+
+  dbg("refresh: $$ refresh $path.lock");
+}
+
+###########################################################################
+
 sub dbg { Mail::SpamAssassin::dbg (@_); }
 
 1;

Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Win32Locker.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Win32Locker.pm	(original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/Win32Locker.pm	Thu Apr  8 09:14:57 2004
@@ -90,6 +90,19 @@
 
 ###########################################################################
 
+sub refresh_lock {
+  my($self, $path) = @_;
+
+  # this could arguably read the lock and make sure the same process
+  # owns it, but this shouldn't, in theory, be an issue.
+  utime time, time, "$path.lock";
+
+  dbg("refresh: $$ refresh $path.lock");
+}
+
+###########################################################################
+
+
 sub dbg { Mail::SpamAssassin::dbg (@_); }
 
 1;