[Exim] Small patch for src/transports/appendfile.c, full ver…

Top Page
Delete this message
Reply to this message
Author: michael
Date:  
To: exim-users
Subject: [Exim] Small patch for src/transports/appendfile.c, full version
Here is the entire patch. Adavantage: Avoids one stat() call on quota
calculation, speeding up the process. Disadavantage: message_size is
not correct, so quota is not 100% correct. Then again, maildir has no
locks, so quota is already not 100% correct.

All in all, things don't get much worse, but they work faster. :)

Michael
----------------------------------------------------------------------
--- src/transports/appendfile.c.orig    Mon Dec 13 15:51:39 1999
+++ src/transports/appendfile.c    Tue Dec 14 10:51:58 1999
@@ -629,11 +629,22 @@
   {
   char *name = ent->d_name;
   char buffer[1024];
+  char *sizeptr;


if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) continue;

count++;

+  if ((sizeptr=strstr(name,",S="))!=(char*)0 && *(sizeptr+3)>='0' && *(sizeptr+3)<='9')
+    {
+      int size=0;
+
+      sizeptr+=3;
+      while (*sizeptr>='0' && *sizeptr<='9') size=size*10+(*sizeptr++-'0');
+      sum += size;
+    }
+  else
+    {
   if (!string_format(buffer, sizeof(buffer), "%s/%s", dirname, name))
     {
     log_write(0, LOG_PANIC|LOG_MAIN, "name too long in check_dir_size: "
@@ -652,6 +663,7 @@
     sum += statbuf.st_size;
   else if ((statbuf.st_mode & S_IFDIR) != 0)
     sum += check_dir_size(buffer, &count);
+    }
   }


closedir(dir);
@@ -1992,8 +2004,8 @@

   for (i = 1;; i++)
     {
-    char *basename = string_sprintf("%lu.%lu.%s%s", time(NULL), getpid(),
-      primary_hostname, tag);
+    char *basename = string_sprintf("%lu.%lu.%s,S=%d%s", time(NULL), getpid(),
+      primary_hostname, message_size, tag);


     filename = dataname = string_sprintf("tmp/%s", basename);
     newname = string_sprintf("new/%s", basename);