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

Re: [leafnode-list] Fetchnews -P



Jeff Grossman <jeff@xxxxxxxxxxx> writes:

> I just removed my main server and tried Fetchnews -P again.  It will only
> post articles to the first server mentioned in the config file.  The
> articles are now deleted from the out.going file because they are already
> available upstream.  So, my original main server must have posted them but
> do not have them available for reading yet.  So, when I removed my main
> server, my second server does have them available, so they are not removed.

Does this patch fix the problem for you?

Index: fetchnews.c
===================================================================
RCS file: /var/CVS/leafnode-2/fetchnews.c,v
retrieving revision 1.119
diff -u -r1.119 fetchnews.c
--- fetchnews.c	14 Jul 2003 10:27:01 -0000	1.119
+++ fetchnews.c	15 Jul 2003 23:57:48 -0000
@@ -767,10 +767,10 @@
 	rc = -1;
     }
 
-    if (log_fsync(tmpfd) || log_close(tmpfd)) {
-	rc = -1;
-	goto out;
-    }
+    if (log_fsync(tmpfd)) rc = -1;
+    if (log_close(tmpfd)) rc = -1;
+    if (rc == -1) goto out;
+
     if (store(mastr_str(tmpfn), 0, 0, 1) == 0) {
 	(void)log_unlink(mastr_str(tmpfn), 0);
     } else {
@@ -1754,7 +1754,6 @@
  * -  0 if no other servers have to be queried (for Message-ID fetch, e. g.)
  * -  1 if no errors, but more servers needed (normal return code)
  * - -1 for non fatal errors (go to next server)
- * - -2 for fatal errors (do not query any more)
  */
 static int
 do_server(int forceactive)
@@ -1763,6 +1762,12 @@
     int rc = -1;	/* assume non fatal errors */
     int res;
     int reply;
+    int flag = 0;
+    enum flags {
+	f_mayshort = 1,
+	f_mustnotshort = 2,
+	f_error = 4
+    };
 
     /* do not try to connect if we don't want to post here in -P mode */
     if (action_method == FETCH_POST
@@ -1798,20 +1803,17 @@
 	goto out;
     }
 
-    rc = 1;	/* now assume success */
-
     check_date(current_server->name);
 
     /* post articles */
     if (action_method & FETCH_POST) {
+	flag |= f_mustnotshort;
 	switch(current_server->feedtype) {
 	    case CPFT_NNTP:
 		if (reply == 200) {
 		    res = postarticles(current_server);
 		    if (res == 0 && rc >= 0)
-			rc = -1;
-		    else if (rc == 0)
-			rc = 1;		/* when posting, query all servers! */
+			flag |= f_error;
 		}
 		break;
 	    case CPFT_NONE:
@@ -1827,7 +1829,7 @@
     /* fetch by MID */
     switch (getmsgidlist(&msgidlist)) {
     case 0:
-	rc = 0;
+	flag |= f_mayshort;
     default:
 	;
     }
@@ -1837,10 +1839,16 @@
 	nntpactive(forceactive);	/* get list of newsgroups or new newsgroups */
 	res = processupstream(current_server->name, current_server->port,
 			forceactive);
-	if (res == 1)
-	    rc = 1;
-	else
-	    rc = -1;
+	if (res != 1)
+	    flag |= f_error;
+    }
+
+    if (flag & f_mustnotshort)
+	flag &= ~f_mayshort;
+    if (flag & f_error) {
+	rc = -1;
+    } else {
+	rc = flag & f_mayshort ? 0 : 1;
     }
 
 out:


-- 
Matthias Andree

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