Archive Mail, Exim and Locking Bug? (was RE: [ MAILSCANNER] Locki ng failing?)

Tony Finch dot at DOTAT.AT
Fri Apr 25 18:16:59 IST 2003


"Desai, Jason" <jase at SENSIS.COM> wrote:
>
>Thanks Tony.  I had just narrowed it down to losing the lock when copying
>the -D file.  If you want me to test any patches just let me know.

I'm testing this at the moment.

--- EximDiskStore.pm    27 Mar 2003 17:28:47 -0000      1.7
+++ EximDiskStore.pm    25 Apr 2003 16:33:27 -0000      1.8
@@ -358,14 +358,22 @@


 # Copy a dfile and hfile to a directory
+# This has to be done in a subprocess in order to avoid breaking POSIX locks.
 sub CopyToDir {
   my($this,$dir) = @_;
+  my $pid = fork;
+  MailScanner::Log::DieLog("fork: $!") if not defined $pid;
+  if ($pid) {
+    waitpid $pid, 0;
+    return;
+  }
   my $hpath = $this->{hpath};
   my $dpath = $this->{dpath};
   my $hfile = basename($hpath);
   my $dfile = basename($dpath);
   copy($hpath, "$dir/$hfile");
   copy($dpath, "$dir/$dfile");
+  exit;
 }


@@ -415,8 +423,18 @@
   if (MailScanner::Config::Value('storeentireasdfqf')) {
     $this->CopyToDir($targetdir);
   } else {
+    # Do this in a subprocess in order to avoid breaking POSIX locks.
+    my $pid = fork;
+    MailScanner::Log::DieLog("fork: $!") if not defined $pid;
+    if ($pid) {
+      waitpid $pid, 0;
+      return;
+    }
     my $target = new IO::File "$targetdir/$targetfile", "w";
+    MailScanner::Log::DieLog("writing to $targetdir/$targetfile: $!")
+           if not defined $target;
     $this->WriteEntireMessage($message, $target);
+    return;
   }

   return 1;
@@ -447,9 +465,9 @@

   my $pipe = new IO::Pipe;
   my $pid;
-
+
   if (not defined $pipe or not defined ($pid = fork)) {
-    MailScanner::Log::WarnLog("Cannot build message from $this->{dpath} " .
+    MailScanner::Log::DieLog("Cannot build message from $this->{dpath} " .
                               "and $message->{headerspath}, %s", $!);
   } elsif ($pid) { # Parent
     $pipe->reader();


Tony.
--
f.a.n.finch  <dot at dotat.at>  http://dotat.at/
MALIN HEBRIDES: EAST OR SOUTHEAST 5 OR 6. RAIN AT TIMES. MODERATE OR GOOD.



More information about the MailScanner mailing list