[exim-dev] [Bug 1086] wrong return value in maildir_ensure_s…

Top Page
Delete this message
Reply to this message
Author: Git Commit
Date:  
To: exim-dev
Subject: [exim-dev] [Bug 1086] wrong return value in maildir_ensure_sizefile
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=1086




--- Comment #6 from Git Commit <git@???> 2011-02-22 04:17:04 ---
Git commit:
http://git.exim.org/exim.git/commitdiff/554e333ebbe0552b61604cdf8fec77f507a3ab9b

commit 554e333ebbe0552b61604cdf8fec77f507a3ab9b
Author:     Phil Pennock <pdp@???>
AuthorDate: Mon Feb 21 22:17:13 2011 -0500
Commit:     Phil Pennock <pdp@???>
CommitDate: Mon Feb 21 22:17:13 2011 -0500


    Don't disable quota when maildirsize lost to races.


    When maildir_ensure_sizefile() returns -2, we still have size
    information, so we can still use that.  Don't disable quota.  As a
    result, do refrain from potentially calling close(-2).


    Fixes bug 1086
---
 src/src/transports/appendfile.c |   19 +++++++------------
 1 files changed, 7 insertions(+), 12 deletions(-)


diff --git a/src/src/transports/appendfile.c b/src/src/transports/appendfile.c
index e5ab657..39dd4f8 100644
--- a/src/src/transports/appendfile.c
+++ b/src/src/transports/appendfile.c
@@ -2419,18 +2419,12 @@ else
           "%s/maildirsize", check_path);
         return FALSE;
         }
-      else if (maildirsize_fd == -2)
-        {
-        DEBUG(D_transport) debug_printf("disabling quota check because of "
-          "races updating %s/maildirsize", check_path);
-        disable_quota = TRUE;
-        }
+      /* can also return -2, which means that the file was removed because of
+      raciness; but in this case, the size & filecount will still have been
+      updated. */


-      if (maildirsize_fd >= 0)
-        {
-        if (mailbox_size < 0) mailbox_size = size;
-        if (mailbox_filecount < 0) mailbox_filecount = filecount;
-        }
+      if (mailbox_size < 0) mailbox_size = size;
+      if (mailbox_filecount < 0) mailbox_filecount = filecount;
       }


     /* No quota enforcement; ensure file does *not* exist; calculate size if
@@ -2927,7 +2921,8 @@ if (!disable_quota)
   if (yield == OK && maildirsize_fd >= 0)
     maildir_record_length(maildirsize_fd, message_size);
   maildir_save_errno = errno;    /* Preserve errno while closing the file */
-  (void)close(maildirsize_fd);
+  if (maildirsize_fd >= 0)
+    (void)close(maildirsize_fd);
   errno = maildir_save_errno;
   }
 #endif  /* SUPPORT_MAILDIR */



--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email