]> diplodocus.org Git - minc/commitdiff
mdeliver/current/mdeliver.c:
authorepg <>
Sun, 19 Jan 2003 03:11:14 +0000 (03:11 +0000)
committerepg <>
Sun, 19 Jan 2003 03:11:14 +0000 (03:11 +0000)
    (deliver): In rev 1582 i changed this from using rename(2) to
    the recommended link(2) + unlink(2).  But in minc i was using
    open(2) + rename(2) instead, which is just as safe as link +
    unlink but with one advantage.  So switch to that model.

minc/current/minc:
    (store_message): Document the open + rename procedure and
    explain why it is used instead of link + unlink.

minc

diff --git a/minc b/minc
index f5ee8bc..7bfec90 100755 (executable)
--- a/minc
+++ b/minc
@@ -428,6 +428,17 @@ sub store_message {
                 # So attempt to create a file with this name.  If it
                 # succeeds, in just a bit here we'll knowingly clobber
                 # this file with the rename(2) call.
+
+                # Another way to do this is not to use rename(2), but
+                # use link(2) + unlink(2) instead.  That's how the
+                # standard maildir algorithm does it.  Each method has
+                # a disadvantage: the program may crash between the
+                # link(2) and unlink(2) calls.  With the standard
+                # maildir algorithm, that means the message will end
+                # up duplicated.  The advantage of creating an empty
+                # file followed by rename(2) is that an extra empty
+                # file is left behind as opposed to a duplicate
+                # message.  This is more easiliy detected by the user.
                 if ($run) {
                     if (sysopen(MSG, "$mhmsg",
                                 O_WRONLY | O_EXCL | O_CREAT, 0600)) {