[leafnode-list] leafnode-1.10.x texpire "relinked message" problem

Matthias Andree matthias.andree at gmx.de
Sat Aug 14 16:14:07 CEST 2004


On Sat, 14 Aug 2004, Rein Klazes wrote:

> I think (it is not tested yet) that it is fetchnews. Activating
> fetchnews during a texpire run will unlink all "mids" files, before
> bailing out because it cannot aquire the lock. 

Ouch.

> The calling sequence is main->initvars->createmsgiddir->log_unlink
> 
> Does that make sense?

Makes a lot of sense, you've found the exact location of the bug: a
leafnode process would happily nuke the mids files while another one
held the lock.

Please try this patch, it is against my current CVS version but also
applies against 1.10.3, you can ignore the "offset -N lines" comments
patch will print - it should fix your problem.

If it does, I'll release 1.10.4 on short notice:

Index: miscutil.c
===================================================================
RCS file: /var/CVS/leafnode-1/miscutil.c,v
retrieving revision 1.56
diff -u -r1.56 miscutil.c
--- miscutil.c	11 Aug 2004 16:57:02 -0000	1.56
+++ miscutil.c	14 Aug 2004 14:00:44 -0000
@@ -101,10 +101,7 @@
 
 	    snprintf(b, sizeof(b), "%03lu", u);
 	    mastr_clear(mid);
-	    if (havedir[u]) {
-		mastr_vcat(mid, spooldir, "/message.id/", b, "/mids", NULL);
-		log_unlink(mastr_str(mid), 1);
-	    } else {
+	    if (!havedir[u]) {
 		mastr_vcat(mid, spooldir, "/message.id/", b, NULL);
 		if (mkdir(mastr_str(mid), 02755)) {
 		    ln_log(LNLOG_SERR, LNLOG_CTOP, "error creating directory %s: %m",
Index: texpire.c
===================================================================
RCS file: /var/CVS/leafnode-1/texpire.c,v
retrieving revision 1.66
diff -u -r1.66 texpire.c
--- texpire.c	11 Aug 2004 18:01:58 -0000	1.66
+++ texpire.c	14 Aug 2004 14:00:44 -0000
@@ -555,6 +555,22 @@
     return rc;
 }
 
+/* returns 0 for success */
+static int
+cleanmids(void)
+{
+    int n, s_len;
+
+    for (n = 0; n < 1000; n++) {
+	char s[SIZE_s+1];
+
+	s_len = xsnprintf(s, SIZE_s, "%s/message.id/%03d/%s", spooldir, n, MIDSFILE);
+	if (log_unlink(s, 1))
+	    return 1;
+    }
+    return 0;
+}
+
 static void
 expiremsgid(void)
 {
@@ -706,6 +722,12 @@
 	exit(1);
     }
 
+    if (cleanmids()) {
+	ln_log(LNLOG_SERR, LNLOG_CTOP, "Cannot weed out MIDS files, aborting.\n");
+	unlink(lockfile);
+	exit(1);
+    }
+
     readactive();
     if (!active) {
 	ln_log(LNLOG_SWARNING, LNLOG_CTOP, "Reading active file failed. Trying to build my own.");

-- 
Matthias Andree

NOTE YOU WILL NOT RECEIVE MY MAIL IF YOU'RE USING SPF!
Encrypted mail welcome: my GnuPG key ID is 0x052E7D95 (PGP/MIME preferred)



More information about the leafnode-list mailing list