[comp.sources.bugs] news 2.11 ihave/sendme bug

craigk@haddock.ISC.COM (Craig Kolb) (07/25/88)

There is a bug in the c_ihave() routine of 2.11 rnews which keeps
sendme messages from being generated in response to ihave messages on
USG systems.

The problem lies in the fact that USG systems to not seek to EOF after
fopening a file for appending until a write() is performed.  Thus, the
first call to ftell() in c_ihave() returns 0 rather than the size of
the temporary file, the code inside the while loop is never executed,
and no articles are requested.

A simple call to fseek() solves the problem.  A context diff follows.

Craig Kolb
craigk@haddock.isc.com

*** /usr/src/local/news/src/control.c	Fri Dec  4 15:17:38 1987
--- control.c	Mon Jul 25 11:18:28 1988
***************
*** 187,192 ****
--- 187,199 ----
  		char		myid[256];
  
  		outfp = xfopen(INFILE, "a");
+ #ifdef USG
+ 		/*
+ 		 * When fopening to append, USG systems don't
+ 		 * seek to EOF until write() is called.
+ 		 */
+ 		fseek(outfp, 0L, 2);
+ #endif
  		outpos = ftell(outfp);
  		inpos = ftell(infp);
  		while (ftell(infp) < outpos) {

jfh@rpp386.UUCP (John F. Haugh II) (07/28/88)

In article <5434@haddock.ISC.COM> craigk@haddock.isc.com (Craig Kolb) writes:
>There is a bug in the c_ihave() routine of 2.11 rnews which keeps
>sendme messages from being generated in response to ihave messages on
>USG systems.
>
>The problem lies in the fact that USG systems to not seek to EOF after
>fopening a file for appending until a write() is performed.  Thus, the
>first call to ftell() in c_ihave() returns 0 rather than the size of
>the temporary file, the code inside the while loop is never executed,
>and no articles are requested.

i just finished checking the source for control.c here.  i am running
ihave/sendme for my primary news feed and i am also running ihave/sendme
for an alt feed.  i don't have trouble with my primary feed though we
are having trouble with the alt feed.  there is no fseek() present prior
to the while() loop as would seem to be required.

i've checked control for sendme's being sent out.  they are in deed
being sent.

- john.
-- 
John F. Haugh II                 +--------- Cute Chocolate Quote ---------
HASA, "S" Division               | "USENET should not be confused with
UUCP:   killer!rpp386!jfh        |  something that matters, like CHOCOLATE"
DOMAIN: jfh@rpp386.uucp          |             -- with my apologizes

craigk@haddock.ISC.COM (Craig Kolb) (07/29/88)

In article <4544@rpp386.UUCP> jfh@rpp386.UUCP (The Beach Bum) writes:
>In article <5434@haddock.ISC.COM> craigk@haddock.isc.com (Craig Kolb) writes:
>
>> [Some complete nonsense I wrote about ihave/sendmes and USG systems.]
>
> [...]  i don't have trouble with my primary feed though we
>are having trouble with the alt feed.  there is no fseek() present prior
>to the while() loop as would seem to be required.
>
>i've checked control for sendme's being sent out.  they are in deed
>being sent.

Yes, you're absolutely right; the original code is correct.  The "bug"
was with the ancient versions of USG-based operating systems that I
tested this on, not USG systems in general.  Bug-free USG systems do,
indeed, return the size of the file when one calls ftell() immediately
after fopening to append.

My apologies to anybody who spent time worrying about this.

Cheers,
Craig
cek@princeton.edu
craigk@haddock.isc.com