dbg.maildirsize
changeset 6 d2183655483b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbg.maildirsize	Sun Feb 20 23:59:48 2011 +0100
@@ -0,0 +1,264 @@
+# HG changeset patch
+# Parent 74c82038542f0fe3e9d80b15ecffc5e2598ef52a
+
+diff -r 74c82038542f src/exim.c
+--- a/src/exim.c	Sat Feb 19 13:30:33 2011 +0100
++++ b/src/exim.c	Sat Feb 19 13:38:06 2011 +0100
+@@ -2206,7 +2206,9 @@
+     else
+       {
+       unsigned int selector = D_default;
++      unsigned int extra_selector = 0;
+       debug_selector = 0;
++      debug_extra_selector = 0;
+       debug_file = NULL;
+       if (*argrest == 'd')
+         {
+@@ -2214,9 +2216,10 @@
+         argrest++;
+         }
+       if (*argrest != 0)
+-        decode_bits(&selector, NULL, D_memory, 0, argrest, debug_options,
++        decode_bits(&selector, &extra_selector, D_memory, 0, argrest, debug_options,
+           debug_options_count, US"debug", 0);
+       debug_selector = selector;
++      debug_extra_selector = extra_selector;
+       }
+     break;
+ 
+@@ -3184,7 +3187,7 @@
+ child processes. It should, of course, be 2 for stderr. Also, force the daemon
+ to run in the foreground. */
+ 
+-if (debug_selector != 0)
++if (debug_selector|debug_extra_selector != 0)
+   {
+   debug_file = stderr;
+   debug_fd = fileno(debug_file);
+diff -r 74c82038542f src/globals.c
+--- a/src/globals.c	Sat Feb 19 13:30:33 2011 +0100
++++ b/src/globals.c	Sat Feb 19 13:38:06 2011 +0100
+@@ -449,6 +449,7 @@
+   { US"load",           D_load },
+   { US"local_scan",     D_local_scan },
+   { US"lookup",         D_lookup },
++  { US"maildirsize",	DX_maildirsize },
+   { US"memory",         D_memory },
+   { US"pid",            D_pid },
+   { US"process_info",   D_process_info },
+@@ -466,6 +467,7 @@
+ };
+ int     debug_options_count    = sizeof(debug_options)/sizeof(bit_table);
+ unsigned int debug_selector    = 0;
++unsigned int debug_extra_selector = 0;
+ int     delay_warning[DELAY_WARNING_SIZE] = { DELAY_WARNING_SIZE, 1, 24*60*60 };
+ uschar *delay_warning_condition=
+   US"${if or {"
+diff -r 74c82038542f src/local_scan.h
+--- a/src/local_scan.h	Sat Feb 19 13:30:33 2011 +0100
++++ b/src/local_scan.h	Sat Feb 19 13:38:06 2011 +0100
+@@ -139,6 +139,7 @@
+ /* Global variables that are documented as visible in the function. */
+ 
+ extern unsigned int debug_selector;    /* Debugging bits */
++extern unsigned int debug_extra_selector;    /* Debugging bits */
+ 
+ extern int     body_linecount;         /* Line count in body */
+ extern int     body_zerocount;         /* Binary zero count in body */
+diff -r 74c82038542f src/log.c
+--- a/src/log.c	Sat Feb 19 13:30:33 2011 +0100
++++ b/src/log.c	Sat Feb 19 13:38:06 2011 +0100
+@@ -1303,7 +1303,7 @@
+ debug_selector = D_default;
+ if (opts)
+   {
+-  decode_bits(&debug_selector, NULL, D_memory, 0, opts,
++  decode_bits(&debug_selector, &debug_extra_selector, D_memory, 0, opts,
+       debug_options, debug_options_count, US"debug", DEBUG_FROM_CONFIG);
+   }
+ 
+diff -r 74c82038542f src/macros.h
+--- a/src/macros.h	Sat Feb 19 13:30:33 2011 +0100
++++ b/src/macros.h	Sat Feb 19 13:38:06 2011 +0100
+@@ -100,7 +100,9 @@
+ 
+ /* Debugging control */
+ 
+-#define DEBUG(x)      if ((debug_selector & (x)) != 0)
++//#define DEBUG(x)      if (((debug_selector & (x)) || (debug_extra_selector & (x))) != 0)
++#define DEBUG(x)      if(x & 0x80000000 ? (debug_extra_selector & ((x) & 0x0fffffff)) : 
++
+ #define HDEBUG(x)     if (host_checking || (debug_selector & (x)) != 0)
+ 
+ /* The default From: text for DSNs */
+@@ -327,6 +329,8 @@
+ #define D_uid                        0x20000000
+ #define D_verify                     0x40000000
+ 
++#define DX_maildirsize               0x80000001
++
+ /* The D_all value must always have all bits set, as it is recognized specially
+ by the function that decodes debug and log selectors. This is to enable it to
+ set all the bits in a multi-word selector. Debug doesn't use this yet, but we
+diff -r 74c82038542f src/transports/tf_maildir.c
+--- a/src/transports/tf_maildir.c	Sat Feb 19 13:30:33 2011 +0100
++++ b/src/transports/tf_maildir.c	Sat Feb 19 13:38:06 2011 +0100
+@@ -215,7 +215,7 @@
+ len = Ustrlen(buffer);
+ (void)lseek(fd, 0, SEEK_END);
+ (void)write(fd, buffer, len);
+-DEBUG(D_transport)
++DEBUG(D_transport|DX_maildirsize)
+   debug_printf("added '%.*s' to maildirsize file\n", len-1, buffer);
+ }
+ 
+@@ -292,7 +292,7 @@
+ 
+   if (Ustat(buffer, &statbuf) < 0)
+     {
+-    DEBUG(D_transport)
++    DEBUG(D_transport|DX_maildirsize)
+       debug_printf("maildir_compute_size: stat error %d for %s: %s\n", errno,
+         buffer, strerror(errno));
+     continue;
+@@ -300,7 +300,7 @@
+ 
+   if ((statbuf.st_mode & S_IFMT) != S_IFDIR)
+     {
+-    DEBUG(D_transport)
++    DEBUG(D_transport|DX_maildirsize)
+       debug_printf("skipping %s/%s: not a directory\n", path, name);
+     continue;
+     }
+@@ -327,7 +327,7 @@
+   }
+ 
+ closedir(dir);
+-DEBUG(D_transport)
++DEBUG(D_transport|DX_maildirsize)
+   {
+   if (timestamp_only)
+     debug_printf("maildir_compute_size (timestamp_only): %ld\n",
+@@ -391,7 +391,7 @@
+ 
+ filename = string_sprintf("%s/maildirsize", path);
+ 
+-DEBUG(D_transport) debug_printf("looking for maildirsize in %s\n", path);
++DEBUG(D_transport|DX_maildirsize) debug_printf("looking for maildirsize in %s\n", path);
+ fd = Uopen(filename, O_CREAT|O_RDWR|O_APPEND, ob->mode ? ob->mode : 0600);
+ if (fd < 0) return -1;
+ 
+@@ -420,7 +420,7 @@
+ count = read(fd, buffer, sizeof(buffer));
+ if (count >= sizeof(buffer))
+   {
+-  DEBUG(D_transport)
++  DEBUG(D_transport|DX_maildirsize)
+     debug_printf("maildirsize file too big (%d): recalculating\n", count);
+   goto RECALCULATE;
+   }
+@@ -428,7 +428,7 @@
+ 
+ /* Read the quota parameters from the first line of the data. */
+ 
+-DEBUG(D_transport)
++DEBUG(D_transport|DX_maildirsize)
+   debug_printf("reading quota parameters from maildirsize data\n");
+ 
+ for (;;)
+@@ -443,7 +443,7 @@
+     else if (*endptr == 'C') cached_quota_filecount = (int)n;
+   if (!isalpha(*endptr++))
+     {
+-    DEBUG(D_transport)
++    DEBUG(D_transport|DX_maildirsize)
+       debug_printf("quota parameter number not followed by letter in "
+         "\"%.*s\": recalculating maildirsize\n", (int)(endptr - buffer),
+         buffer);
+@@ -452,7 +452,7 @@
+   if (*endptr == '\n' || *endptr == 0) break;
+   if (*endptr++ != ',')
+     {
+-    DEBUG(D_transport)
++    DEBUG(D_transport|DX_maildirsize)
+       debug_printf("quota parameter not followed by comma in "
+         "\"%.*s\": recalculating maildirsize\n", (int)(endptr - buffer),
+         buffer);
+@@ -466,7 +466,7 @@
+ if (cached_quota != ob->quota_value ||
+     cached_quota_filecount != ob->quota_filecount_value)
+   {
+-  DEBUG(D_transport)
++  DEBUG(D_transport|DX_maildirsize)
+     debug_printf("cached quota is out of date: recalculating\n"
+       "  quota=" OFF_T_FMT " cached_quota=" OFF_T_FMT " filecount_quota=%d "
+       "cached_quota_filecount=%d\n", ob->quota_value,
+@@ -477,7 +477,7 @@
+ /* Quota values agree; parse the rest of the data to get the sizes. At this
+ stage, *endptr points either to 0 or to '\n'.  */
+ 
+-DEBUG(D_transport)
++DEBUG(D_transport|DX_maildirsize)
+   debug_printf("computing maildir size from maildirsize data\n");
+ 
+ while (*endptr++ == '\n')
+@@ -502,7 +502,7 @@
+   {
+   if (size < 0 || filecount < 0)
+     {
+-    DEBUG(D_transport) debug_printf("negative value in maildirsize "
++    DEBUG(D_transport|DX_maildirsize) debug_printf("negative value in maildirsize "
+       "(size=" OFF_T_FMT " count=%d): recalculating\n", size, filecount);
+     goto RECALCULATE;
+     }
+@@ -517,7 +517,7 @@
+     struct stat statbuf;
+     if (linecount > 1)
+       {
+-      DEBUG(D_transport) debug_printf("over quota and maildirsize has "
++      DEBUG(D_transport|DX_maildirsize) debug_printf("over quota and maildirsize has "
+         "more than 1 entry: recalculating\n");
+       goto RECALCULATE;
+       }
+@@ -526,7 +526,7 @@
+ 
+     if (time(NULL) - statbuf.st_mtime > 15*60)
+       {
+-      DEBUG(D_transport) debug_printf("over quota and maildirsize is older "
++      DEBUG(D_transport|DX_maildirsize) debug_printf("over quota and maildirsize is older "
+         "than 15 minutes: recalculating\n");
+       goto RECALCULATE;
+       }
+@@ -543,7 +543,7 @@
+   uschar *tempname;
+   struct timeval tv;
+ 
+-  DEBUG(D_transport)
++  DEBUG(D_transport|DX_maildirsize)
+     {
+     uschar *p = endptr;
+     while (p > buffer && p[-1] != '\n') p--;
+@@ -587,12 +587,12 @@
+   /* If any of the directories have been modified since the last timestamp we
+   saw, we have to junk this maildirsize file. */
+ 
+-  DEBUG(D_transport) debug_printf("checking subdirectory timestamps\n");
++  DEBUG(D_transport|DX_maildirsize) debug_printf("checking subdirectory timestamps\n");
+   new_latest = 0;
+   (void)maildir_compute_size(path, NULL, &new_latest , NULL, dir_regex, TRUE);
+   if (new_latest > old_latest)
+     {
+-    DEBUG(D_transport) debug_printf("abandoning maildirsize because of "
++    DEBUG(D_transport|DX_maildirsize) debug_printf("abandoning maildirsize because of "
+       "a later subdirectory modification\n");
+     (void)Uunlink(filename);
+     (void)close(fd);
+@@ -604,7 +604,7 @@
+ lock.l_type = F_UNLCK;
+ if (fd > 0) fcntl(fd, F_SETLKW, &lock);
+ 
+-DEBUG(D_transport) debug_printf("returning maildir size=" OFF_T_FMT
++DEBUG(D_transport|DX_maildirsize) debug_printf("returning maildir size=" OFF_T_FMT
+   " filecount=%d\n", size, filecount);
+ *returned_size = size;
+ *returned_filecount = filecount;