[news.software.nntp] Can 'rrn' check for new news?

phil@east.Berkeley.EDU (Phil Lapsley) (05/16/88)

rrn can't check for new news as distributed.  On startup it snarfs
the active file from the server and makes a local copy.  Since the
local copy doesn't change, rrn doesn't think there is new news.

Next release, I guess.

						Phil

ljz@fxgrp.fx.com (Lloyd Zusman) (05/16/88)

In article <3417@pasteur.Berkeley.Edu> phil@east.Berkeley.EDU (Phil Lapsley) writes:
>rrn can't check for new news as distributed.  On startup it snarfs
>the active file from the server and makes a local copy.  Since the
>local copy doesn't change, rrn doesn't think there is new news.
> ...

Well, since that's the way it is, I decided to fix it.

Here is a patch to 'rrn'.  It works with the latest version of 'rrn'
that I have been able to locate.  It took me about an hour to do, but
it works just fine for me.  My apologies in advance if it is overly
simple and overlooks something important that might break 'rrn' under
some conditions.

It adds a new command line-option "-A" (for "check news *A*gain")
which, if set, causes 'rrn' to check for new news once it has gone
through all the newsgroups.  When this option is set, 'rrn' will never
set the default reply to "q" at the "End of newsgroups--what next?"
prompt, thereby allowing this check to be repeated over and over until
"q" is explicitly typed.

Enjoy.

--
    Lloyd Zusman
    Master Byte Software
    Los Gatos, California		Internet: ljz@fx.com
    "We take things well in hand."	UUCP:     ...!ames!fxgrp!ljz

--------------------------- Patch begins here ----------------------------

*** Configure	Sun May 15 17:23:27 1988
--- Configure.new	Sun May 15 17:54:25 1988
***************
*** 2074,2079 ****
--- 2074,2081 ----
  #$isrrn         SERVER          /* rrn server code */
  #$isrrn SERVER_HOST     "$rrnserver"
  #$isrrn SERVER_FILE	"$serverfile"
+ 
+ #define CHECK_ON_EXIT	/* check for new news before exit if -A option */
  EOT
  
  CONFIG=true
*** common.h	Sun May 15 17:00:33 1988
--- common.h.new	Sun May 15 17:54:38 1988
***************
*** 726,731 ****
--- 726,735 ----
      EXT int scanon INIT(0);				/* -S */
  #endif
  
+ #ifdef CHECK_ON_EXIT
+     EXT bool check_again_before_exit INIT(FALSE);	/* -A */
+ #endif /* CHECK_ON_EXIT */
+ 
  EXT bool mbox_always INIT(FALSE);			/* -M */
  EXT bool norm_always INIT(FALSE);			/* -N */
  EXT bool checkflag INIT(FALSE);			/* -c */
*** config.h	Sun May 15 17:32:53 1988
--- config.h.new	Sun May 15 17:55:31 1988
***************
*** 81,83 ****
--- 81,84 ----
  #define         SERVER          /* rrn server code */
  #define SERVER_HOST     ""
  #define SERVER_FILE	"/usr/new/lib/rn/nntp_server"
+ #define CHECK_ON_EXIT	/* check for new news before exit if -A option */
*** rn.c	Sun May 15 16:39:40 1988
--- rn.c.new	Sun May 15 17:55:41 1988
***************
*** 111,116 ****
--- 111,131 ----
  		mode = 'n';
  		if (ng >= nextrcline) {	/* after the last newsgroup? */
  		    ng = nextrcline;	/* force it to 1 after */
+ #ifdef CHECK_ON_EXIT
+ 		    if (check_again_before_exit) {
+ 			    /*
+ 			     * See if any new news has arrived before giving
+ 			     * the caller a chance to exit.
+ 			     */
+ 			    ngdata_init();
+ 			    foundany = rcstuff_init();
+ 			    if (foundany) {
+ 				    ng = starthere = 0;
+ 				    continue;
+ 			    }
+ 		    }
+ #endif /* CHECK_ON_EXIT */
+ 
  #ifdef ONLY
  		    if (maxngtodo) {
  			if (retry)
***************
*** 139,144 ****
--- 154,167 ----
  			}
  		    }
  #endif
+ #ifdef CHECK_ON_EXIT
+ 		    /*
+ 		     * Never default to 'q' when -A is selected.
+ 		     */
+ 		    if (check_again_before_exit)
+ 			    dfltcmd = "npq";
+ 		    else
+ #endif /* CHECK_ON_EXIT */
  		    dfltcmd = (retry ? "npq" : "qnp");
  #ifdef VERBOSE
  		    IF(verbose)

ljz@fxgrp.UUCP (Lloyd Zusman) (05/16/88)

In article <322@fxgrp.UUCP> ljz@fx.com (Lloyd Zusman) writes:

[ A patch to 'rrn' for rechecking news before exit from 'rrn' ].

WARNING!!!!!!!!

DON'T USE THIS PATCH!!!!!!!

IT DOESN'T WORK!!!

I MADE A BIG ERROR.  IT TRASHES .newsrc UNDER SOME CONDITIIONS.

PLEASE ACCEPT MY HUMBLE APOLOGIES.


--
    Lloyd Zusman
    Master Byte Software
    Los Gatos, California		Internet: ljz@fx.com
    "We take things well in hand."	UUCP:     ...!ames!fxgrp!ljz

simon@its63b.UUCP (05/17/88)

Keywords:

>>rrn can't check for new news as distributed.  On startup it snarfs
>>the active file from the server and makes a local copy.  Since the
>>local copy doesn't change, rrn doesn't think there is new news.
>> ...
>
>Well, since that's the way it is, I decided to fix it.
>
>Here is a patch to 'rrn' ... It adds a new command line-option ... which, if 
> set, causes 'rrn' to check for new news once it has gone through all the 
> newsgroups.  When this option is set, 'rrn' will never set the default reply 
> to "q" at the "End of newsgroups--what next?" prompt, thereby allowing this 
> check to be repeated over and over until "q" is explicitly typed.

Aargh! This seems a pretty crude/bizarre way of doing it. A more reasonable 
approach would be to send a request to the server, saying "send me the active 
file again, if it's more recent than my local cache copy". Then, when the
end-of-newsgroups is reached - if new news has arrived, the active file will
be resent, the default reply is set to 'n' and you continue, otherwise it'll
be set to 'q' and the default is quit. Of course, I imagine NNTP can't provide
such services (can it?).

	Simon.

flee@gondor.cs.psu.edu.UUCP (05/21/88)

In article <1357@its63b.ed.ac.uk> simon%lfcs.ed.ac.uk@nss.cs.ucl.ac.uk
(Simon Brown) writes:
> Aargh! This seems a pretty crude/bizarre way of doing it.

Okay.  Here is a different set of patches to rrn.  The active file
gets grabbed automagically when you reach the End of Newsgroups prompt.
No "-A" option needed.

A much better but more difficult solution would be to use the information
that the server gives you when you send a "GROUP" command.  Except the
effort isn't really worth it.  I'd just as soon wait for rn version 5.0.
--
Felix Lee	flee@gondor.cs.psu.edu	*!psuvax1!gondor!flee


diff -c -r4.3 rn.c
*** /tmp/,RCSt1001373	Fri May 20 21:27:25 1988
--- rn.c	Fri May 20 13:55:49 1988
***************
*** 88,98 ****
--- 88,104 ----
  	bool special = FALSE;		/* temporarily allow newsgroup */
  					/*   with no unread news? */
  	bool retry;			/* cycle back to top of list? */
+ #ifdef SERVER
+ 	bool reretry;			/* get the active file again? */
+ #endif
  	NG_NUM recent_ng = 0;
  	
  	current_ng = 0;
  	do {
  	    retry = FALSE;
+ #ifdef SERVER
+ 	    reretry = FALSE;
+ #endif
  	    if (findlast) {
  		findlast = FALSE;
  		starthere = 0;
***************
*** 143,148 ****
--- 149,162 ----
  			}
  		    }
  #endif
+ #ifdef SERVER
+ 		    if (retry || reretry) {
+ 			(void) fclose(actfp);
+ 			ngdata_init();		/* get the active file again */
+ 			retry = TRUE;
+ 			reretry = FALSE;
+ 		    }
+ #endif
  		    dfltcmd = (retry ? "npq" : "qnp");
  #ifdef VERBOSE
  		    IF(verbose)
***************
*** 177,182 ****
--- 191,199 ----
  			ng++;		/* then skip it */
  			continue;
  		    }
+ #ifdef SERVER
+ 		    reretry = TRUE;	/* there's a non-empty newsgroup. */
+ #endif
  		    dfltcmd = "ynq";
  #ifdef VERBOSE
  		    IF(verbose)

flee@gondor.cs.psu.edu.UUCP (05/21/88)

One caveat about my patch.  You will notice that the "=" command doesn't
show new articles after 'rrn' rereads the active file.  Don't panic.
This is not a problem with rrn.

The problem is with the server.  'nntpd' reads the active file into an array
when it starts up.  This array *never ever* gets updated.  Curiously enough,
if you ask the server "LIST", nntpd will read the active file again.  But it
still doesn't update the array.

This affects rrn's "=" command and article searching.  Everything else
functions normally.  The easiest fix is to quit out of rrn.  A better
fix would be to patch nntp/server/list.c.  Coming soon to a newsgroup
near you...
--
Felix Lee	flee@gondor.cs.psu.edu	*!psuvax1!gondor!flee