changeset 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 b2a4f839affd
children a7882c8e180c
files ChangeLog src/fetch.c src/pseudo.c src/pseudo.h src/server.c
diffstat 5 files changed, 44 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Dec 05 19:30:50 2000 +0000
+++ b/ChangeLog	Tue Dec 05 19:50:09 2000 +0000
@@ -1,3 +1,11 @@
+Tue Dec 05 2000 Markus Enzenberger <markus.enzenberger@t-online.de>
+
+    * src/fetch.c,src/Makefile.in: use sendmail instead of mail
+
+    * src/fetch.c,src/pseudo.c,src/pseudo.h,src/server.c: applied
+    patch from Matija Nalis: better handling of inconsistent counters
+    at remote server; do not read overview on each group command
+
 Thu Oct 26 21:42:45 BST 2000 Jim Hague <jim.hague@acm.org>
 
  * src/protocol.c: Fix bug in Prt_getLn if we should read a line
--- a/src/fetch.c	Tue Dec 05 19:30:50 2000 +0000
+++ b/src/fetch.c	Tue Dec 05 19:50:09 2000 +0000
@@ -1,7 +1,7 @@
 /*
   fetch.c
 
-  $Id: fetch.c 235 2000-12-05 19:30:50Z enz $
+  $Id: fetch.c 236 2000-12-05 19:50:09Z enz $
 */
 
 #if HAVE_CONFIG_H
@@ -81,7 +81,7 @@
 static void
 fetchNewArts( const char *name, FetchMode mode )
 {
-    int next, first, last;
+    int next, first, last, refetch;
 
     if ( ! Client_changeToGrp( name ) )
     {
@@ -113,9 +113,12 @@
     }
     if ( next > last + 1 )
     {
-        Log_err( "Article number inconsistent (%s rmt=%lu-%lu, next=%lu)",
-                 name, first, last, next );
-        Pseudo_cntInconsistent( name, first, last, next );
+    	refetch = last - Cfg_maxFetch() + 1;
+    	if ( refetch < 0 ) refetch = 1;
+        Log_err( "Article number inconsistent (%s rmt=%lu-%lu, next=%lu). Refetching from %lu",
+                 name, first, last, next, refetch );
+        Pseudo_cntInconsistent( name, first, last, next, refetch );
+        first = refetch;
     }
     else if ( next < first )
     {
--- a/src/pseudo.c	Tue Dec 05 19:30:50 2000 +0000
+++ b/src/pseudo.c	Tue Dec 05 19:50:09 2000 +0000
@@ -1,7 +1,7 @@
 /*
   pseudo.c
   
-  $Id: pseudo.c 111 2000-05-19 15:13:44Z bears $
+  $Id: pseudo.c 236 2000-12-05 19:50:09Z enz $
 */
 
 #if HAVE_CONFIG_H
@@ -250,7 +250,7 @@
 }
 
 void
-Pseudo_cntInconsistent( const char *grp, int first, int last, int next )
+Pseudo_cntInconsistent( const char *grp, int first, int last, int next, int refetch )
 {
     DynStr *info;
     Str s;
@@ -272,6 +272,8 @@
         DynStr_appLn( info, s );
         snprintf( s, MAXCHAR, "Remote next article number: %i", next );
         DynStr_appLn( info, s );
+        snprintf( s, MAXCHAR, "Refetching from article: %i", refetch );
+        DynStr_appLn( info, s );
         genPseudo( "Article counter inconsistent", DynStr_str( info ) );
     }
     del_DynStr( info );
--- a/src/pseudo.h	Tue Dec 05 19:30:50 2000 +0000
+++ b/src/pseudo.h	Tue Dec 05 19:50:09 2000 +0000
@@ -3,7 +3,7 @@
 
   Handling of pseudo articles.
 
-  $Id: pseudo.h 51 2000-05-05 23:49:38Z uh1763 $
+  $Id: pseudo.h 236 2000-12-05 19:50:09Z enz $
 */
 
 #ifndef PSEUDO_H
@@ -54,7 +54,7 @@
  */
 
 void
-Pseudo_cntInconsistent( const char *grp, int first, int last, int next );
+Pseudo_cntInconsistent( const char *grp, int first, int last, int next, int refetch );
 
 void
 Pseudo_missArts( const char *grp, int first, int next );
--- 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 )