dbg.maildirsize
changeset 6 d2183655483b
equal deleted inserted replaced
5:399967a8bbf1 6:d2183655483b
       
     1 # HG changeset patch
       
     2 # Parent 74c82038542f0fe3e9d80b15ecffc5e2598ef52a
       
     3 
       
     4 diff -r 74c82038542f src/exim.c
       
     5 --- a/src/exim.c	Sat Feb 19 13:30:33 2011 +0100
       
     6 +++ b/src/exim.c	Sat Feb 19 13:38:06 2011 +0100
       
     7 @@ -2206,7 +2206,9 @@
       
     8      else
       
     9        {
       
    10        unsigned int selector = D_default;
       
    11 +      unsigned int extra_selector = 0;
       
    12        debug_selector = 0;
       
    13 +      debug_extra_selector = 0;
       
    14        debug_file = NULL;
       
    15        if (*argrest == 'd')
       
    16          {
       
    17 @@ -2214,9 +2216,10 @@
       
    18          argrest++;
       
    19          }
       
    20        if (*argrest != 0)
       
    21 -        decode_bits(&selector, NULL, D_memory, 0, argrest, debug_options,
       
    22 +        decode_bits(&selector, &extra_selector, D_memory, 0, argrest, debug_options,
       
    23            debug_options_count, US"debug", 0);
       
    24        debug_selector = selector;
       
    25 +      debug_extra_selector = extra_selector;
       
    26        }
       
    27      break;
       
    28  
       
    29 @@ -3184,7 +3187,7 @@
       
    30  child processes. It should, of course, be 2 for stderr. Also, force the daemon
       
    31  to run in the foreground. */
       
    32  
       
    33 -if (debug_selector != 0)
       
    34 +if (debug_selector|debug_extra_selector != 0)
       
    35    {
       
    36    debug_file = stderr;
       
    37    debug_fd = fileno(debug_file);
       
    38 diff -r 74c82038542f src/globals.c
       
    39 --- a/src/globals.c	Sat Feb 19 13:30:33 2011 +0100
       
    40 +++ b/src/globals.c	Sat Feb 19 13:38:06 2011 +0100
       
    41 @@ -449,6 +449,7 @@
       
    42    { US"load",           D_load },
       
    43    { US"local_scan",     D_local_scan },
       
    44    { US"lookup",         D_lookup },
       
    45 +  { US"maildirsize",	DX_maildirsize },
       
    46    { US"memory",         D_memory },
       
    47    { US"pid",            D_pid },
       
    48    { US"process_info",   D_process_info },
       
    49 @@ -466,6 +467,7 @@
       
    50  };
       
    51  int     debug_options_count    = sizeof(debug_options)/sizeof(bit_table);
       
    52  unsigned int debug_selector    = 0;
       
    53 +unsigned int debug_extra_selector = 0;
       
    54  int     delay_warning[DELAY_WARNING_SIZE] = { DELAY_WARNING_SIZE, 1, 24*60*60 };
       
    55  uschar *delay_warning_condition=
       
    56    US"${if or {"
       
    57 diff -r 74c82038542f src/local_scan.h
       
    58 --- a/src/local_scan.h	Sat Feb 19 13:30:33 2011 +0100
       
    59 +++ b/src/local_scan.h	Sat Feb 19 13:38:06 2011 +0100
       
    60 @@ -139,6 +139,7 @@
       
    61  /* Global variables that are documented as visible in the function. */
       
    62  
       
    63  extern unsigned int debug_selector;    /* Debugging bits */
       
    64 +extern unsigned int debug_extra_selector;    /* Debugging bits */
       
    65  
       
    66  extern int     body_linecount;         /* Line count in body */
       
    67  extern int     body_zerocount;         /* Binary zero count in body */
       
    68 diff -r 74c82038542f src/log.c
       
    69 --- a/src/log.c	Sat Feb 19 13:30:33 2011 +0100
       
    70 +++ b/src/log.c	Sat Feb 19 13:38:06 2011 +0100
       
    71 @@ -1303,7 +1303,7 @@
       
    72  debug_selector = D_default;
       
    73  if (opts)
       
    74    {
       
    75 -  decode_bits(&debug_selector, NULL, D_memory, 0, opts,
       
    76 +  decode_bits(&debug_selector, &debug_extra_selector, D_memory, 0, opts,
       
    77        debug_options, debug_options_count, US"debug", DEBUG_FROM_CONFIG);
       
    78    }
       
    79  
       
    80 diff -r 74c82038542f src/macros.h
       
    81 --- a/src/macros.h	Sat Feb 19 13:30:33 2011 +0100
       
    82 +++ b/src/macros.h	Sat Feb 19 13:38:06 2011 +0100
       
    83 @@ -100,7 +100,9 @@
       
    84  
       
    85  /* Debugging control */
       
    86  
       
    87 -#define DEBUG(x)      if ((debug_selector & (x)) != 0)
       
    88 +//#define DEBUG(x)      if (((debug_selector & (x)) || (debug_extra_selector & (x))) != 0)
       
    89 +#define DEBUG(x)      if(x & 0x80000000 ? (debug_extra_selector & ((x) & 0x0fffffff)) : 
       
    90 +
       
    91  #define HDEBUG(x)     if (host_checking || (debug_selector & (x)) != 0)
       
    92  
       
    93  /* The default From: text for DSNs */
       
    94 @@ -327,6 +329,8 @@
       
    95  #define D_uid                        0x20000000
       
    96  #define D_verify                     0x40000000
       
    97  
       
    98 +#define DX_maildirsize               0x80000001
       
    99 +
       
   100  /* The D_all value must always have all bits set, as it is recognized specially
       
   101  by the function that decodes debug and log selectors. This is to enable it to
       
   102  set all the bits in a multi-word selector. Debug doesn't use this yet, but we
       
   103 diff -r 74c82038542f src/transports/tf_maildir.c
       
   104 --- a/src/transports/tf_maildir.c	Sat Feb 19 13:30:33 2011 +0100
       
   105 +++ b/src/transports/tf_maildir.c	Sat Feb 19 13:38:06 2011 +0100
       
   106 @@ -215,7 +215,7 @@
       
   107  len = Ustrlen(buffer);
       
   108  (void)lseek(fd, 0, SEEK_END);
       
   109  (void)write(fd, buffer, len);
       
   110 -DEBUG(D_transport)
       
   111 +DEBUG(D_transport|DX_maildirsize)
       
   112    debug_printf("added '%.*s' to maildirsize file\n", len-1, buffer);
       
   113  }
       
   114  
       
   115 @@ -292,7 +292,7 @@
       
   116  
       
   117    if (Ustat(buffer, &statbuf) < 0)
       
   118      {
       
   119 -    DEBUG(D_transport)
       
   120 +    DEBUG(D_transport|DX_maildirsize)
       
   121        debug_printf("maildir_compute_size: stat error %d for %s: %s\n", errno,
       
   122          buffer, strerror(errno));
       
   123      continue;
       
   124 @@ -300,7 +300,7 @@
       
   125  
       
   126    if ((statbuf.st_mode & S_IFMT) != S_IFDIR)
       
   127      {
       
   128 -    DEBUG(D_transport)
       
   129 +    DEBUG(D_transport|DX_maildirsize)
       
   130        debug_printf("skipping %s/%s: not a directory\n", path, name);
       
   131      continue;
       
   132      }
       
   133 @@ -327,7 +327,7 @@
       
   134    }
       
   135  
       
   136  closedir(dir);
       
   137 -DEBUG(D_transport)
       
   138 +DEBUG(D_transport|DX_maildirsize)
       
   139    {
       
   140    if (timestamp_only)
       
   141      debug_printf("maildir_compute_size (timestamp_only): %ld\n",
       
   142 @@ -391,7 +391,7 @@
       
   143  
       
   144  filename = string_sprintf("%s/maildirsize", path);
       
   145  
       
   146 -DEBUG(D_transport) debug_printf("looking for maildirsize in %s\n", path);
       
   147 +DEBUG(D_transport|DX_maildirsize) debug_printf("looking for maildirsize in %s\n", path);
       
   148  fd = Uopen(filename, O_CREAT|O_RDWR|O_APPEND, ob->mode ? ob->mode : 0600);
       
   149  if (fd < 0) return -1;
       
   150  
       
   151 @@ -420,7 +420,7 @@
       
   152  count = read(fd, buffer, sizeof(buffer));
       
   153  if (count >= sizeof(buffer))
       
   154    {
       
   155 -  DEBUG(D_transport)
       
   156 +  DEBUG(D_transport|DX_maildirsize)
       
   157      debug_printf("maildirsize file too big (%d): recalculating\n", count);
       
   158    goto RECALCULATE;
       
   159    }
       
   160 @@ -428,7 +428,7 @@
       
   161  
       
   162  /* Read the quota parameters from the first line of the data. */
       
   163  
       
   164 -DEBUG(D_transport)
       
   165 +DEBUG(D_transport|DX_maildirsize)
       
   166    debug_printf("reading quota parameters from maildirsize data\n");
       
   167  
       
   168  for (;;)
       
   169 @@ -443,7 +443,7 @@
       
   170      else if (*endptr == 'C') cached_quota_filecount = (int)n;
       
   171    if (!isalpha(*endptr++))
       
   172      {
       
   173 -    DEBUG(D_transport)
       
   174 +    DEBUG(D_transport|DX_maildirsize)
       
   175        debug_printf("quota parameter number not followed by letter in "
       
   176          "\"%.*s\": recalculating maildirsize\n", (int)(endptr - buffer),
       
   177          buffer);
       
   178 @@ -452,7 +452,7 @@
       
   179    if (*endptr == '\n' || *endptr == 0) break;
       
   180    if (*endptr++ != ',')
       
   181      {
       
   182 -    DEBUG(D_transport)
       
   183 +    DEBUG(D_transport|DX_maildirsize)
       
   184        debug_printf("quota parameter not followed by comma in "
       
   185          "\"%.*s\": recalculating maildirsize\n", (int)(endptr - buffer),
       
   186          buffer);
       
   187 @@ -466,7 +466,7 @@
       
   188  if (cached_quota != ob->quota_value ||
       
   189      cached_quota_filecount != ob->quota_filecount_value)
       
   190    {
       
   191 -  DEBUG(D_transport)
       
   192 +  DEBUG(D_transport|DX_maildirsize)
       
   193      debug_printf("cached quota is out of date: recalculating\n"
       
   194        "  quota=" OFF_T_FMT " cached_quota=" OFF_T_FMT " filecount_quota=%d "
       
   195        "cached_quota_filecount=%d\n", ob->quota_value,
       
   196 @@ -477,7 +477,7 @@
       
   197  /* Quota values agree; parse the rest of the data to get the sizes. At this
       
   198  stage, *endptr points either to 0 or to '\n'.  */
       
   199  
       
   200 -DEBUG(D_transport)
       
   201 +DEBUG(D_transport|DX_maildirsize)
       
   202    debug_printf("computing maildir size from maildirsize data\n");
       
   203  
       
   204  while (*endptr++ == '\n')
       
   205 @@ -502,7 +502,7 @@
       
   206    {
       
   207    if (size < 0 || filecount < 0)
       
   208      {
       
   209 -    DEBUG(D_transport) debug_printf("negative value in maildirsize "
       
   210 +    DEBUG(D_transport|DX_maildirsize) debug_printf("negative value in maildirsize "
       
   211        "(size=" OFF_T_FMT " count=%d): recalculating\n", size, filecount);
       
   212      goto RECALCULATE;
       
   213      }
       
   214 @@ -517,7 +517,7 @@
       
   215      struct stat statbuf;
       
   216      if (linecount > 1)
       
   217        {
       
   218 -      DEBUG(D_transport) debug_printf("over quota and maildirsize has "
       
   219 +      DEBUG(D_transport|DX_maildirsize) debug_printf("over quota and maildirsize has "
       
   220          "more than 1 entry: recalculating\n");
       
   221        goto RECALCULATE;
       
   222        }
       
   223 @@ -526,7 +526,7 @@
       
   224  
       
   225      if (time(NULL) - statbuf.st_mtime > 15*60)
       
   226        {
       
   227 -      DEBUG(D_transport) debug_printf("over quota and maildirsize is older "
       
   228 +      DEBUG(D_transport|DX_maildirsize) debug_printf("over quota and maildirsize is older "
       
   229          "than 15 minutes: recalculating\n");
       
   230        goto RECALCULATE;
       
   231        }
       
   232 @@ -543,7 +543,7 @@
       
   233    uschar *tempname;
       
   234    struct timeval tv;
       
   235  
       
   236 -  DEBUG(D_transport)
       
   237 +  DEBUG(D_transport|DX_maildirsize)
       
   238      {
       
   239      uschar *p = endptr;
       
   240      while (p > buffer && p[-1] != '\n') p--;
       
   241 @@ -587,12 +587,12 @@
       
   242    /* If any of the directories have been modified since the last timestamp we
       
   243    saw, we have to junk this maildirsize file. */
       
   244  
       
   245 -  DEBUG(D_transport) debug_printf("checking subdirectory timestamps\n");
       
   246 +  DEBUG(D_transport|DX_maildirsize) debug_printf("checking subdirectory timestamps\n");
       
   247    new_latest = 0;
       
   248    (void)maildir_compute_size(path, NULL, &new_latest , NULL, dir_regex, TRUE);
       
   249    if (new_latest > old_latest)
       
   250      {
       
   251 -    DEBUG(D_transport) debug_printf("abandoning maildirsize because of "
       
   252 +    DEBUG(D_transport|DX_maildirsize) debug_printf("abandoning maildirsize because of "
       
   253        "a later subdirectory modification\n");
       
   254      (void)Uunlink(filename);
       
   255      (void)close(fd);
       
   256 @@ -604,7 +604,7 @@
       
   257  lock.l_type = F_UNLCK;
       
   258  if (fd > 0) fcntl(fd, F_SETLKW, &lock);
       
   259  
       
   260 -DEBUG(D_transport) debug_printf("returning maildir size=" OFF_T_FMT
       
   261 +DEBUG(D_transport|DX_maildirsize) debug_printf("returning maildir size=" OFF_T_FMT
       
   262    " filecount=%d\n", size, filecount);
       
   263  *returned_size = size;
       
   264  *returned_filecount = filecount;