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

Re: [leafnode-list] Date:-less posts freeze fetchnews.



Joshua Crawford <mortarn@xxxxxxxxxxxx> writes:

> After this, there is no network activity, and no output (I left it for
> 20minutes before killing it).

I see suspect code in fetchnews.c around line #1151.

I think the patch below fixes the problem, can you try it and report
back (It includes other changes, log below.)

----------------------------
revision 1.111
date: 2003/06/20 22:57:48;  author: emma;  state: Exp;  lines: +10 -4
Fix a bug that got introduced after 1.9.41.rel: bodies of articles were
no longer downloaded at all.
Fix long-standing bug: when a mandatory header was missing from an
upstream article, fetchnews would behave strangely; a hang was reported
by Joshua Crawford <mortarn@xxxxxxxxxxxx>.
----------------------------
revision 1.110
date: 2003/06/06 13:52:09;  author: emma;  state: Exp;  lines: +11 -6
Fix bogus "Cannot open /var/spool/news/interesting.groups/group.name for reading" after unsubscribing; reported by Andreas Muck.
----------------------------
revision 1.109
date: 2003/05/26 12:42:47;  author: emma;  state: Exp;  lines: +11 -9
Check lastreply() against NULL. Reported by Bruno Rohee.
=============================================================================
Index: fetchnews.c
===================================================================
RCS file: /var/CVS/leafnode-1/fetchnews.c,v
retrieving revision 1.108
retrieving revision 1.111
diff -u -r1.108 -r1.111
--- fetchnews.c	20 May 2003 21:29:27 -0000	1.108
+++ fetchnews.c	20 Jun 2003 22:57:48 -0000	1.111
@@ -78,7 +78,7 @@
 static void supersede(const char *msgid);
 #endif
 static unsigned long getgroup( /*@null@*/ struct newsgroup *g,
-			      unsigned long server);
+			      unsigned long server, int *);
 static int postarticles(void);
 
 static void
@@ -657,7 +657,7 @@
  * was previously read from this group on that server
  */
 static unsigned long
-getgroup(struct newsgroup *g, unsigned long server)
+getgroup(struct newsgroup *g, unsigned long server, int *unsubscribed)
 {
 #define HD_MAX 10
     static char *hd[HD_MAX];
@@ -689,6 +689,8 @@
     if (!g)
 	return server;
 
+    *unsubscribed = 0;
+
     if (g->first > g->last && g->first - g->last > 1)
 	g->last = g->first - 1;
 
@@ -836,6 +838,7 @@
 	    syslog(LOG_INFO, "unsubscribing from %s (current time: %ld): "
 		   "ctime age %ld, mtime age %ld", g->name, (long)now,
 		   (long)now - st.st_ctime, (long)now - st.st_mtime);
+	    *unsubscribed = 1;
 	    unlink(s);
 	    return server;
 	}
@@ -1121,7 +1124,7 @@
 		printf("...saw header %s\n", hnames[n]);
 	    free(l);
 	    l = NULL;
-	}
+	} /* end while */
 	if (l)
 	    free(l);
 
@@ -1145,10 +1148,15 @@
 		       stufftoget[i], hnames[h]);
 		killed++;
 		if (requested_body) ignore_answer(nntpin);
-		continue;
+		takethis = 0;
+		break;
 	    }
 	}
 
+	/* mandatory header missing */
+	if (!takethis)
+	    continue;
+
 	if (localmaxage && age(hd[5]) > localmaxage) {
 	    if (verbose > 2)
 		printf("Discarding article %lu - older than %d days\n",
@@ -1159,6 +1167,7 @@
 	    if (requested_body) ignore_answer(nntpin);
 	    continue;
 	}
+
 	if (minlines || maxlines) {
 	    char *t;
 	    t = strchr(hd[7], ' ');
@@ -1415,10 +1424,10 @@
 	xsnprintf(lineout, SIZE_lineout, "NEWGROUPS %s GMT\r\n", timestr + 2);
 	putaline();
 	if (nntpreply() != 231) {
-	    printf("Reading new newsgroups failed, reason \"%s\".\n",
-		    lastreply());
-	    syslog(LOG_ERR, "Reading new newsgroups failed, reason \"%s\"",
-		    lastreply());
+	    char *e = lastreply();
+	    if (!e) e = "premature disconnect";
+	    printf("Reading new newsgroups failed, reason \"%s\".\n", e);
+	    syslog(LOG_ERR, "Reading new newsgroups failed, reason \"%s\"", e);
 	    return -1;
 	}
 	while ((l = getaline(nntpin)) && (*l != '.')) {
@@ -1495,10 +1504,10 @@
 	xsnprintf(lineout, SIZE_lineout, "LIST\r\n");
 	putaline();
 	if (nntpreply() != 215) {
-	    printf("Reading all newsgroups failed, reason \"%s\".\n",
-		    lastreply());
-	    syslog(LOG_ERR, "Reading all newsgroups failed, reason \"%s\".\n",
-		    lastreply());
+	    char *e = lastreply();
+	    if (!e) e = "premature disconnect";
+	    printf("Reading all newsgroups failed, reason \"%s\".\n", e);
+	    syslog(LOG_ERR, "Reading all newsgroups failed, reason \"%s\".\n", e);
 	    return -1;
 	}
 	debug = 0;
@@ -1638,11 +1647,13 @@
 	    putaline();
 	    r = nntpreply();
 	    if (r != 340) {
+		char *e = lastreply();
+		if (!e) e = "premature disconnect";
 		xsnprintf(s, SIZE_s, "%s/failed.postings/%s", spooldir,
 			  de->d_name);
 		ln_log(LNLOG_SERR, LNLOG_CARTICLE,
 			"unable to post (%d), moving to %s, reason: \"%s\"",
-			r, s, lastreply());
+			r, s, e);
 		if (rename(de->d_name, s))
 		    ln_log(LNLOG_SERR, LNLOG_CARTICLE,
 			    "unable to move failed posting to %s: %m", s);
@@ -1857,6 +1868,7 @@
     }
     while ((de = readdir(d))) {
 	if (isalnum((unsigned char)*(de->d_name))) {
+	    int unsubscribed;
 	    g = findgroup(de->d_name);
 	    if (g != NULL) {
 		xsnprintf(s, SIZE_s, "%s ", g->name);
@@ -1867,17 +1879,18 @@
 		    l = strchr(l, ' ');
 		    srv = strtoul(l, &t, 10);
 		    if (t && !*t)
-			newserver = getgroup(g, srv);
+			newserver = getgroup(g, srv, &unsubscribed);
 		    else
-			newserver = getgroup(g, 1ul);
+			newserver = getgroup(g, 1ul, &unsubscribed);
 		} else {
-		    newserver = getgroup(g, 1ul);
+		    newserver = getgroup(g, 1ul, &unsubscribed);
 		}
 		/* run this independent of delaybody mode, because
 		 * the admin may have switched delaybody off recently,
 		 * and we still want users to be able to retrieve
 		 * articles. */
-		getmarked(g);
+		if (!unsubscribed)
+		    getmarked(g);
 		if (f != NULL) {
 		    fprintf(f, "%s %lu\n", g->name, newserver);
 		}


-- 
Matthias Andree

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