[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [leafnode-list] maxage == 0



Jonathan Larmour <jifl@xxxxxxxxxx> writes:

> leafnode seems to whinge overly about what I believe to be a correct use
> of maxage == 0.
>
> I think the attached patch (against 1.9.27) makes sense... localmaxage
> should be left at maxage, and only changed if the global or group expiry
> is greater. I don't see why maxage being set to 0 should affect these
> limits as the whole point of setting maxage to 0 is to prevent any
> checking *at all*.

You have a point.

> For that matter I'm unclear what setting clamp_maxage = 0 is meant to
> achieve anyway. The only time clamp_maxage is tested is when the value
> of 0 tells you via syslog that your configuration is broken and should
> be fixed.

Indeed, maxage == 0 was hosed by some past checkin. Thanks for finding
and reporting this.

How about this patch instead?

Index: configutil.c
===================================================================
RCS file: /var/CVS/leafnode-1/configutil.c,v
retrieving revision 1.26
diff -u -r1.26 configutil.c
--- configutil.c	19 Oct 2002 10:44:08 -0000	1.26
+++ configutil.c	21 Nov 2002 01:31:15 -0000
@@ -201,6 +201,10 @@
 		int i = atoi(value);
 		if (i >= (INT_MAX / SECONDS_PER_DAY))
 		    i = (INT_MAX / SECONDS_PER_DAY) - 1;
+		if (i <= 0) {
+		    ln_log(LNLOG_SERR, LNLOG_CTOP, "config: expire must be positive, not %d, abort", i);
+		    exit(1);
+		}
 		expiredays = i;
 		expire = time(NULL) - (time_t) (SECONDS_PER_DAY * i);
 		if (debugmode)
@@ -247,7 +251,7 @@
 		maxbytes = strtol(value, NULL, 10);
 		if (debugmode)
 		    syslog(LOG_DEBUG,
-			   "config: postings have max. %ld bytes", maxbytes);
+			   "config: postings have max. %lu bytes", maxbytes);
 	    } else if (strcmp("linebuffer", param) == 0) {
 		linebuffer = atoi(value);
 		if (debugmode)
@@ -417,6 +421,11 @@
 			l);
 	    }
 	}
+    }
+    if (maxage != 0 && maxage > expiredays && clamp_maxage == 0) {
+	ln_log(LNLOG_SERR, LNLOG_CTOP,
+		"config: maxage (%d) > expire (%d). This can cause duplicate download. Please fix your configuration, maxage must not be greater than expire.",
+		maxage, expiredays);
     }
     debug = debugmode;
 
Index: fetchnews.c
===================================================================
RCS file: /var/CVS/leafnode-1/fetchnews.c,v
retrieving revision 1.75
diff -u -r1.75 fetchnews.c
--- fetchnews.c	21 Nov 2002 01:05:34 -0000	1.75
+++ fetchnews.c	21 Nov 2002 01:31:15 -0000
@@ -609,23 +609,29 @@
     (void)chdirgroup(g->name, TRUE);
 
     if ((exp = lookup_expiredays(g->name)) > 0) {
-	if ((localmaxage == 0) || (localmaxage > exp)) {
+	if (localmaxage > exp) {
 	    maxagelimit = exp;
 	    limitfrom = "groupexpire";
 	}
     } else {
-	if (localmaxage == 0 || localmaxage > expiredays) {
+	if (localmaxage > expiredays) {
 	    maxagelimit = expiredays;
 	    limitfrom = "global expire";
 	}
     }
 
-    if (*limitfrom) {
+    if (*limitfrom && localmaxage > maxagelimit) {
 	if (clamp_maxage) {
 	    syslog(LOG_NOTICE, "clamping maxage for %s to %s %d",
 		   g->name, limitfrom, maxagelimit);
 	    localmaxage = maxagelimit;
 	} else {
+	    fprintf(stderr,
+		   "warning: group %s: maxage of %d is inappropriate for your "
+		   "applicable %s of %d. This can cause excessive downloads of "
+		   "articles that were previously downloaded and expired. "
+		   "Fix your configuration.\n", g->name, localmaxage, limitfrom,
+		   maxagelimit);
 	    syslog(LOG_WARNING,
 		   "warning: group %s: maxage of %d is inappropriate for your "
 		   "applicable %s of %d. This can cause excessive downloads of "


-- 
Matthias Andree

http://sourceforge.net/projects/leafnode/   - leafnode-1 tarballs
http://mandree.home.pages.de/leafnode/beta/ - leafnode-2 tarballs

-- 
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx -- mailing list for leafnode
To unsubscribe, send mail with "unsubscribe" in the subject to the list