Avoid unnecessary scan of maildir mailbox when mailbox_size is set but
authorPhilip Hazel <ph10@hermes.cam.ac.uk>
Wed, 1 Mar 2006 11:24:04 +0000 (11:24 +0000)
committerPhilip Hazel <ph10@hermes.cam.ac.uk>
Wed, 1 Mar 2006 11:24:04 +0000 (11:24 +0000)
mailbox_filecount and quota_filecount are not.

doc/doc-txt/ChangeLog
src/src/transports/appendfile.c
test/confs/5008 [new file with mode: 0644]
test/log/5008 [new file with mode: 0644]
test/scripts/5000-maildir/5008 [new file with mode: 0644]
test/stderr/5008 [new file with mode: 0644]

index 5344cbd0122f0b7315a05ef80421ab015d005629..ffdc0a165857a59cafc034bfbc7f3238b266b94f 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.317 2006/03/01 10:40:03 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.318 2006/03/01 11:24:04 ph10 Exp $
 
 Change log file for Exim from version 4.21
 -------------------------------------------
@@ -245,6 +245,13 @@ PH/48 The ${prvs expansion was broken on systems where time_t was long long.
 
 PH/49 Installed latest patch from the Sieve maintainer.
 
+PH/50 When an Exim quota was set without a file count quota, and mailbox_size
+      was also set, the appendfile transport was unnecessarily scanning a
+      directory of message files (e.g. for maildir delivery) to find the count
+      of files (along with the size), even though it did not need this
+      information. It now does the scan only if it needs to find either the
+      size of the count of files.
+
 
 Exim version 4.60
 -----------------
index 142d5570399d9213d1d53166b01d20fba6238eba..7a415de7ae6c3cfce3127384e58e77a53f5a82fe 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/transports/appendfile.c,v 1.13 2006/02/21 16:24:20 ph10 Exp $ */
+/* $Cambridge: exim/src/src/transports/appendfile.c,v 1.14 2006/03/01 11:24:04 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -2317,13 +2317,14 @@ else
     }
   #endif  /* SUPPORT_MAILDIR */
 
-  /* Otherwise (mailbox_size is not yet set), if we are going to do a quota
-  check later on, find the current size of the mailbox. (We don't need to check
-  ob->quota_filecount_value, because it can only be set if ob->quota_value is
-  set.) */
+  /* Otherwise if we are going to do a quota check later on, and the mailbox
+  size is not set, find the current size of the mailbox. Ditto for the file
+  count. Note that ob->quota_filecount_value cannot be set without
+  ob->quota_value being set. */
 
-  if ((mailbox_size < 0 || mailbox_filecount < 0) &&
-      (ob->quota_value > 0 || THRESHOLD_CHECK))
+  if ((ob->quota_value > 0 || THRESHOLD_CHECK) &&
+      (mailbox_size < 0 ||
+        (mailbox_filecount < 0 && ob->quota_filecount_value > 0)))
     {
     off_t size;
     int filecount = 0;
diff --git a/test/confs/5008 b/test/confs/5008
new file mode 100644 (file)
index 0000000..9e77ba0
--- /dev/null
@@ -0,0 +1,50 @@
+# Exim test configuration 5008
+
+QUOTA_FILECOUNT=0
+
+exim_path = EXIM_PATH
+host_lookup_order = bydns
+primary_hostname = myhost.test.ex
+rfc1413_query_timeout = 0s
+spool_directory = DIR/spool
+log_file_path = DIR/spool/log/%slog
+gecos_pattern = ""
+gecos_name = CALLER_NAME
+
+
+# ----- Main settings -----
+
+delay_warning =
+qualify_domain = test.ex
+
+
+# ----- Routers -----
+
+begin routers
+
+r1:
+  driver = accept
+  transport = t1
+
+# ----- Transports -----
+
+begin transports
+
+t1:
+  driver = appendfile
+  directory = DIR/test-mail/$local_part
+  user = CALLER
+  maildir_format
+  mailbox_size = 100K
+  quota = 1M
+  quota_filecount = QUOTA_FILECOUNT
+
+
+# ----- Retry -----
+
+begin retry
+
+* * F,1d,1d
+
+
+# End
diff --git a/test/log/5008 b/test/log/5008
new file mode 100644 (file)
index 0000000..1f37fd3
--- /dev/null
@@ -0,0 +1,6 @@
+1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@test.ex U=CALLER P=local S=sss
+1999-03-02 09:44:33 10HmaX-0005vi-00 => userx <userx@test.ex> R=r1 T=t1
+1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
+1999-03-02 09:44:33 10HmaY-0005vi-00 <= CALLER@test.ex U=CALLER P=local S=sss
+1999-03-02 09:44:33 10HmaY-0005vi-00 => userx <userx@test.ex> R=r1 T=t1
+1999-03-02 09:44:33 10HmaY-0005vi-00 Completed
diff --git a/test/scripts/5000-maildir/5008 b/test/scripts/5000-maildir/5008
new file mode 100644 (file)
index 0000000..0c50423
--- /dev/null
@@ -0,0 +1,9 @@
+# mailbox_size and mailbox_filecount
+#
+exim -d-all+transport -odi userx@test.ex
+Test message
+****
+exim -DQUOTA_FILECOUNT=20 -d-all+transport -odi userx@test.ex
+Test message
+****
+no_message_check
diff --git a/test/stderr/5008 b/test/stderr/5008
new file mode 100644 (file)
index 0000000..5c2b23f
--- /dev/null
@@ -0,0 +1,77 @@
+Exim version x.yz ....
+configuration file is TESTSUITE/test-config
+admin user
+LOG: MAIN
+  <= CALLER@test.ex U=CALLER P=local S=sss
+created log directory TESTSUITE/spool/log
+Exim version x.yz ....
+configuration file is TESTSUITE/test-config
+trusted user
+admin user
+>>>>>>>>>>>>>>>> Local deliveries >>>>>>>>>>>>>>>>
+--------> userx@test.ex <--------
+appendfile transport entered
+appendfile: mode=600 notify_comsat=0 quota=1048576 warning=0
+  directory=TESTSUITE/test-mail/userx format=maildir
+  message_prefix=null
+  message_suffix=null
+  maildir_use_size_file=no
+ensuring maildir directories exist in TESTSUITE/test-mail/userx
+created directory TESTSUITE/test-mail/userx
+created directory TESTSUITE/test-mail/userx/tmp
+created directory TESTSUITE/test-mail/userx/new
+created directory TESTSUITE/test-mail/userx/cur
+delivering in maildir format in TESTSUITE/test-mail/userx
+writing to tmp/MAILDIR.myhost.test.ex
+Exim quota = 1048576 old size = sssss this message = sss (included)
+  file count quota = 0 count = -1
+writing data block fd=6 size=sss timeout=0
+renaming temporary file
+renamed tmp/MAILDIR.myhost.test.ex as new/MAILDIR.myhost.test.ex
+appendfile yields 0 with errno=dd more_errno=dd
+t1 transport returned OK for userx@test.ex
+LOG: MAIN
+  => userx <userx@test.ex> R=r1 T=t1
+LOG: MAIN
+  Completed
+>>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>>
+>>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>>
+Exim version x.yz ....
+configuration file is TESTSUITE/test-config
+admin user
+LOG: MAIN
+  <= CALLER@test.ex U=CALLER P=local S=sss
+Exim version x.yz ....
+configuration file is TESTSUITE/test-config
+trusted user
+admin user
+>>>>>>>>>>>>>>>> Local deliveries >>>>>>>>>>>>>>>>
+--------> userx@test.ex <--------
+appendfile transport entered
+appendfile: mode=600 notify_comsat=0 quota=1048576 warning=0
+  directory=TESTSUITE/test-mail/userx format=maildir
+  message_prefix=null
+  message_suffix=null
+  maildir_use_size_file=no
+ensuring maildir directories exist in TESTSUITE/test-mail/userx
+quota checks on directory TESTSUITE/test-mail/userx
+MUNGED: the check_dir_size lines have been sorted to ensure consistency
+check_dir_size: dir=TESTSUITE/test-mail/userx sum=dddd count=dd
+check_dir_size: dir=TESTSUITE/test-mail/userx/cur sum=0 count=dd
+check_dir_size: dir=TESTSUITE/test-mail/userx/new sum=dddd count=dd
+check_dir_size: dir=TESTSUITE/test-mail/userx/tmp sum=0 count=dd
+delivering in maildir format in TESTSUITE/test-mail/userx
+writing to tmp/MAILDIR.myhost.test.ex
+Exim quota = 1048576 old size = sssss this message = sss (included)
+  file count quota = 20 count = 4
+writing data block fd=6 size=sss timeout=0
+renaming temporary file
+renamed tmp/MAILDIR.myhost.test.ex as new/MAILDIR.myhost.test.ex
+appendfile yields 0 with errno=dd more_errno=dd
+t1 transport returned OK for userx@test.ex
+LOG: MAIN
+  => userx <userx@test.ex> R=r1 T=t1
+LOG: MAIN
+  Completed
+>>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>>
+>>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>>