patch to fix the group out-of-sync problem

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

 



Hi:
	I'm not sure if this is the correct way to fix the
problem.  (For those who didn't see the original report,
the problem is that if you enter a cached group by a group
command, the remote server remains in whatever state it is
before the command, and thus any subsequent article or xover
commands sent to the remote server will lead to undefined
results).  Anyway, I used server_cfg.group to store the actual
group on the remote side.  And change it only if a group
command is successfully carried out on the remote side.
On the other hand, this is checked everytime CMDarticle or
CMDxover or CMDxhdr is called and interaction with the
remote side is required.  I have not done an exhaustive search
of all the files for other potential places to insert this
check so there might still be problems.  All comments are welcome.

PS This seems to have fixed my corrupted overview record problem.

-- 
Debian GNU/Linux 1.1 is out! { http://www.debian.org/ }
Email:  Herbert Xu ~{PmV>HI~} <herbert@greathan.apana.org.au>
{ http://greathan.apana.org.au/~herbert/ }
PGP Key:  pgp-public-keys@pgp.mit.edu or any other key sites
--
diff -u nntpcache-current.orig/article.c nntpcache-current/article.c
--- nntpcache-current.orig/article.c	Thu Sep  5 12:23:48 1996
+++ nntpcache-current/article.c	Sun Sep 29 11:26:54 1996
@@ -552,11 +552,34 @@
 				else
 					sprintf (args, "body %d", artno);
 			}
+
+			if (!syncGroup())
+			{
+				emitrn (NNTP_NOTINGROUP);
+				return FALSE;
+			}
+
 			Cemitrn (args);
 			Cflush ();
 		}
 	} else /* not cached */
 	{
+		if (!syncGroup())
+		{
+			emitrn (NNTP_NOTINGROUP);
+			return FALSE;
+		}
+
 		Cemitrn (args);
 		Cflush ();
 	}
diff -u nntpcache-current.orig/group.c nntpcache-current/group.c
--- nntpcache-current.orig/group.c	Thu Sep  5 01:02:06 1996
+++ nntpcache-current/group.c	Sun Sep 29 11:25:54 1996
@@ -156,7 +156,6 @@
 		}
 		CurrentGroupArtNum = getLo(n);
 	}
-end:
 	if (!scfg->group || !strEq(scfg->group, group))
 	{
 		if (scfg->group)
@@ -164,6 +163,7 @@
 		scfg->group = Sstrdup(group);
 		logd (("current newsgroup now %s:%s", scfg->host, group));
 	}
+end:
 	CurrentScfg = CurrentGroupScfg = scfg;
 	strcpy (CurrentGroup, group);
 	return TRUE;
@@ -367,4 +367,24 @@
 #endif
 		}
 	}
+}
+
+X (bool syncGroup ())
+{
+	char bfr[MAX_BFR] = "";
+
+	if (!CurrentScfg->group || !strEq(CurrentScfg->group, CurrentGroup))
+	{
+		Cemitf ("group %s\r\n", CurrentGroup);
+		Cflush ();
+		if (!Cget (bfr, sizeof(bfr))) return FALSE;
+
+		if (CurrentScfg->group) free(CurrentScfg->group);
+		CurrentScfg->group = Sstrdup(CurrentGroup);
+
+		logd (("current newsgroup now %s:%s",
+		       CurrentScfg->host, CurrentGroup));
+	}
+
+	return TRUE;
 }
diff -u nntpcache-current.orig/xover.c nntpcache-current/xover.c
--- nntpcache-current.orig/xover.c	Thu Sep  5 01:02:07 1996
+++ nntpcache-current/xover.c	Sun Sep 29 11:27:48 1996
@@ -683,6 +683,8 @@
 		 */
 		if (min)
 		{
+			if (!syncGroup()) return FALSE;
+
 			xover_output (min, max);
 			return TRUE;
 		}
@@ -921,6 +923,12 @@
 	{
 		char line[MAX_LINE];
 		    
+		if (!syncGroup())
+		{
+			emitrn (NNTP_NOTINGROUP);
+			return;
+		}
+
 		Cemit (args);
 		Cflush ();
 		if (!Cget (line, sizeof line))
@@ -996,6 +1004,12 @@
 		struct server_cfg *osrvrs = ServerList;
 		struct server_cfg *cf;
 
+		if (!syncGroup())
+		{
+			emitrn (NNTP_NOTINGROUP);
+			return;
+		}
+
 		Cemit (args);
 		Cflush ();
 		if (!Cget (buf, sizeof buf))
@@ -1077,6 +1091,12 @@
 	}
 	if (CurrentScfg->xover_timeout < 1 || !isFieldInXover(header) || !CurrentScfg->overview_fmt)
 	{
+		if (!syncGroup())
+		{
+			emitrn (NNTP_NOTINGROUP);
+			return;
+		}
+
 		Cemit (args);
 		Cflush ();
 		if (!Cget (buf, sizeof buf))


[Index of Archives]     [Yosemite]     [Yosemite Campsites]     [Bugtraq]     [Linux]     [Trn]

Powered by Linux