[net.news.b] Minor bug in readnews

root@aaec.OZ (Superuser) (11/13/85)

Description:
	If there are a number of missing directories for newsgroups
	mentioned in the active file then "readnews" prints the message

		Can't open <directory>

	at seemingly random times when listing headers or skipping
	newsgroups.  This is despite the fact that there are no articles
	currently in the indicated newsgroup.  (i.e. the lower bound
	equals the upper bound.)

	(News version: B 2.10.3 alpha 4/15/85, although the problem
	is also in B 2.10.2 and, I suspect, even earlier versions)

Repeat-by:
	After deleting all the empty directories in /usr/spool/news
	run
		readnews -x -l > /dev/null

	and watch the errors reported.

Diagnosis:
	This is caused by not reseting the variable "noaccess" on
	entry to a new newsgroup (i.e. directory).  So on the
	third missing directory in a row it prints the message.
	(It's incremented twice for each missing directory!)

Fix-by:
	Adding the following patch to the function "readr".
	(Actually a lot of the code around here could be rewritten
	to check the newsgroup bound more efficiently.)

*** readr.c.old	Tue Jun  4 05:53:54 1985
--- readr.c	Wed Nov 13 19:37:13 1985
***************
*** 982,993
  				if (!xflag)
  					fprintf(stderr,"[Saving .newsrc]\n");
  				writeoutrc();
  				timelastsaved = now;
  			}
  		}
  	}
  
  nextart2:
  #ifdef DEBUG
  	fprintf(stderr, "article: %s/%ld\n", groupdir, bit);
  #endif

--- 982,994 -----
  				if (!xflag)
  					fprintf(stderr,"[Saving .newsrc]\n");
  				writeoutrc();
  				timelastsaved = now;
  			}
  		}
+ 		noaccess = 0;
  	}
  
  nextart2:
  #ifdef DEBUG
  	fprintf(stderr, "article: %s/%ld\n", groupdir, bit);
  #endif

-----
Frank Crawford

ACSnet:	root@aaec.OZ
UUCP:	{seismo,mcvax,ukc,prlb2,ubc-vision}!munnari!aaec.OZ!root

Australian Atomic Energy Commission		Phone: +61 2 543 3094
Private Mailbag,
SUTHERLAND,
N.S.W.  2232
Australia.

rees@apollo.uucp (Jim Rees) (11/18/85)

That isn't the only thing wrong with getnextart().  It doesn't work well
when you have a new active file (because you just installed news), it writes
out newsrc even with the -x flag, and it fills up errlog with one-line,
1000-byte messages when the spool directory isn't available.

Here are some fixes for these problems.

***************
*** 909,914
  			} else
  				if (rfq++ || pflag || cflag)
  					return 1;
  		}
  		if (rflag)
  			bit = ngsize + 1;

--- 927,933 -----
  			} else
  				if (rfq++ || pflag || cflag)
  					return 1;
+ 			break;
  		}
  		if (rflag)
  			bit = ngsize + 1;
***************
*** 914,920
  			bit = ngsize + 1;
  		else
  			bit = minartno - 1;
! 		if (uflag) {
  			time_t now;
  			(void) time(&now);
  			if (now - timelastsaved > 5*60 /* 5 minutes */) {

--- 933,939 -----
  			bit = ngsize + 1;
  		else
  			bit = minartno - 1;
! 		if (uflag && !xflag) {
  			time_t now;
  			(void) time(&now);
  			if (now - timelastsaved > 5*60 /* 5 minutes */) {
***************
*** 950,956
  	fprintf(stderr, "filename = '%s'\n", filename);
  #endif
  	/* Decide if we want to show this article. */
!  	if ((fp = fopen(filename, "r")) == NULL) {
   		/* since there can be holes in legal article numbers, */
   		/* we wait till we hit 5 consecutive bad articles */
   		/* before we haul off and scan the directory */

--- 970,997 -----
  	fprintf(stderr, "filename = '%s'\n", filename);
  #endif
  	/* Decide if we want to show this article. */
!  	if (bit <= 0 || (fp = fopen(filename, "r")) == NULL) {
   		/* since there can be holes in legal article numbers, */
   		/* we wait till we hit 5 consecutive bad articles */
   		/* before we haul off and scan the directory */
***************
*** 960,966
   		dirp = opendir(dirname(groupdir));
   		if (dirp == NULL) {
  			if (errno != EACCES)
! 				fprintf(stderr,"Can't open %s", dirname(groupdir));
   			goto badart;
   		}
   		nextnum = rflag ? minartno - 1 : ngsize + 1;

--- 1001,1007 -----
   		dirp = opendir(dirname(groupdir));
   		if (dirp == NULL) {
  			if (errno != EACCES)
! 				fprintf(stderr,"Can't open %s\n", dirname(groupdir));
   			goto badart;
   		}
   		nextnum = rflag ? minartno - 1 : ngsize + 1;