diff src/server.c @ 155:22b81617d427 noffle

[svn] applied patch from Matija Nalis: better handling of inconsistent counters at remote server; do not read overview on each group command
author enz
date Tue, 05 Dec 2000 19:50:09 +0000
parents bfeea2bc09b6
children 23a53c92d4d7
line wrap: on
line diff
--- a/src/server.c	Tue Dec 05 19:30:50 2000 +0000
+++ b/src/server.c	Tue Dec 05 19:50:09 2000 +0000
@@ -1,7 +1,7 @@
 /*
   server.c
 
-  $Id: server.c 225 2000-10-26 21:13:28Z bears $
+  $Id: server.c 236 2000-12-05 19:50:09Z enz $
 */
 
 #if HAVE_CONFIG_H
@@ -57,7 +57,8 @@
     Str grp; /* selected group, "" if none */
     DynStr *reply;
     Bool eotAfterReply;
-} server = { FALSE, 0L, 0, "", NULL, FALSE };
+    Bool groupReady;
+} server = { FALSE, 0L, 0, "", NULL, FALSE, FALSE };
 
 typedef struct Cmd
 {
@@ -307,6 +308,7 @@
     Utl_cpyStr( server.grp, grp );
     readCont( grp );
     server.artPtr = Cont_first();
+    server.groupReady = TRUE;
 }
 
 static Bool
@@ -320,9 +322,11 @@
         putStat( STAT_NO_SUCH_GRP, "No such group" );
     else
     {
-        changeToGrp( arg );
-        first = Cont_first();
-        last = Cont_last();
+	Utl_cpyStr( server.grp, arg );
+	server.groupReady = FALSE;
+	server.artPtr = Grp_first( arg );
+	first = server.artPtr;
+	last = Grp_last( arg );
 	if ( ( first == 0 && last == 0 )
 	     || first > last )
             first = last = numb = 0;
@@ -335,13 +339,19 @@
 }
 
 static Bool
-testGrpSelected( void )
+loadGrpIfSelected( void )
 {
+    Str group;
     if ( *server.grp == '\0' )
     {
         putStat( STAT_NO_GRP_SELECTED, "No group selected" );
         return FALSE;
     }
+    if ( ! server.groupReady )
+    {
+    	Utl_cpyStr( group, server.grp );
+    	changeToGrp( group );
+    }
     return TRUE;
 }
 
@@ -395,7 +405,7 @@
 static Bool
 checkNumb( int numb )
 {
-    if ( ! testGrpSelected() )
+    if ( ! loadGrpIfSelected() )
         return FALSE;
     if ( ! Cont_validNumb( numb ) )
     {
@@ -628,7 +638,7 @@
     UNUSED( arg );
     UNUSED( cmd );
 
-    if ( testGrpSelected() )
+    if ( loadGrpIfSelected() )
     {
         n = server.artPtr;
         if ( ! Cont_validNumb( n ) )
@@ -929,7 +939,7 @@
     UNUSED(arg);
     UNUSED(cmd);
 
-    if ( testGrpSelected() )
+    if ( loadGrpIfSelected() )
     {
         n = server.artPtr;
         if ( ! Cont_validNumb( n ) )
@@ -1157,7 +1167,7 @@
 	Str field;
 	
 	/* Argument is article no. or range */
-	if ( ! testGrpSelected() )
+	if ( ! loadGrpIfSelected() )
 	    return TRUE;
 	parseRange( p, &first, &last, &numb );
 	if ( numb == 0 )
@@ -1222,7 +1232,7 @@
 	int first, last, i, n, numb;
 
 	/* Argument is article no. or range */
-	if ( ! testGrpSelected() )
+	if ( ! loadGrpIfSelected() )
 	    return TRUE;
 	parseRange( articles, &first, &last, &numb );
 	if ( numb == 0 )
@@ -1291,7 +1301,7 @@
 
     UNUSED( cmd );
     
-    if ( ! testGrpSelected() )
+    if ( ! loadGrpIfSelected() )
         return TRUE;
     parseRange( arg, &first, &last, &n );
     if ( n == 0 )