[patch] Creating new index files (was Re: [tpop3d-discuss] SIGBUS)

Paul Makepeace beasts.org at paulm.com
Tue, 12 Aug 2003 23:10:29 +0100


On Wed, Aug 06, 2003 at 05:31:55PM +0100, Paul Makepeace wrote:
> Coincidentally(?) I'm also seeing a lot of errors issuing from
> there, typically
> 
> [snip]
> Aug  6 17:23:36 mythix tpop3d[10416]: mailspool_load_index(<index2>): No such file or directory

This patch (or at least the idea of it) suppresses these warnings when
the file hasn't been created yet, and forces the index to be created
when it's not there. The pervasion of current warnings can arise
AFAICS from a zero length mailbox being checked repeatedly but because
there are no new messages it repeatedly isn't created, gobbling /var,
and agitating me.

(Maybe could have a LOG_{INFO,DEBUG} to say it's not there but scheduled
for creation.)

--- mailspool.c 29 Jul 2003 13:16:05 -0000      1.45
+++ mailspool.c 12 Aug 2003 22:02:21 -0000
@@ -675,2 +676,3 @@
     int num, r;
+    int index_missing = 0;
 
@@ -683,3 +685,6 @@
     if (!fp) {
-        log_print(LOG_WARNING, "mailspool_load_index(%s): %m",
         indexfile);
+        if (errno == ENOENT)
+            index_missing = 1; /* create it at the end */
+        else
+            log_print(LOG_WARNING, "mailspool_load_index(%s): %m", indexfile);
         goto fail;
@@ -765,3 +770,3 @@
     r = mailspool_build_index(m, filemem);
-    if (m->num > num) mailspool_save_index(m);
+    if (m->num > num || index_missing) mailspool_save_index(m);
     return r;

Paul, has a mild fetish about reducing >= LOG_WARNING


-- 
Paul Makepeace ....................................... http://paulm.com/

"If I were a girl, then eating humble pie wouldn't make me pass wind
 like the Gods."
   -- http://paulm.com/toys/surrealism/