[news.software.b] Some TMNN-7.8 diffs

urlichs@ira.uka.de (Matthias Urlichs) (10/06/89)

These diffs to tmnn 7.8 fix some major bugs.
Expire should run now. :-)

These patches (or something resembling them) were also sent
to erik@snark.uu.net, but he didn't reply yet.

Under A/UX, expire -s crashes (segmentation fault) while writing the
active file. Anyone know what happens here? I suspect some memory allocation
trouble (it crashes in fprintf. :-( ).

The first of these diffs is necessary to get anything resembling performance
when reading the active file -- delete it if your machine is mentioned in
that part of rdactive.c.

Under Ultrix 3.0, delete dirent.h and sys/dirent.h from D.include.

Enjoy.

diff -r -c2 src.orig/D.news/rdactive.c src/D.news/rdactive.c
*** src.orig/D.news/rdactive.c	Thu Jul 20 10:01:10 1989
--- src/D.news/rdactive.c	Tue Oct  3 14:47:17 1989
***************
*** 342,346 ****
  	 * general will be covered by the ngnewart() change.
  	 */
! 	(void) setbuf(active.fp, (char *)NULL);
      }
      else if ((active.fp = fopen(ACTIVE, "r")) == (FILE *)NULL)
--- 342,346 ----
  	 * general will be covered by the ngnewart() change.
  	 */
! 	/* (void) setbuf(active.fp, (char *)NULL); */
      }
      else if ((active.fp = fopen(ACTIVE, "r")) == (FILE *)NULL)
diff -r -c2 src.orig/D.priv/filelock.c src/D.priv/filelock.c
*** src.orig/D.priv/filelock.c	Mon Aug 28 04:28:51 1989
--- src/D.priv/filelock.c	Tue Oct  3 18:47:27 1989
***************
*** 80,84 ****
      if ((fd = open(file, O_RDONLY, 0)) < 0)
      {
! 	logerr1("fileunlock: open: errno = %d", errno);
  	return(FAIL);
      }
--- 80,85 ----
      if ((fd = open(file, O_RDONLY, 0)) < 0)
      {
! 	if(errno != ENOENT)
! 	    logerr1("fileunlock: open: errno = %d", errno);
  	return(FAIL);
      }
***************
*** 89,92 ****
--- 90,94 ----
  #endif /* LOCKF */
  
+ #ifndef HAVELOCKS
  #ifdef BSD4_2
  #define HAVELOCKS
***************
*** 132,136 ****
      if ((fd = open(file, 0)) == FAIL)
      {
! 	logerr1("fileunlock: open: errno = %d", errno);
  	return(FAIL);
      }
--- 134,139 ----
      if ((fd = open(file, 0)) == FAIL)
      {
! 	if(errno != 2)
! 	    logerr1("fileunlock: open: errno = %d", errno);
  	return(FAIL);
      }
***************
*** 141,145 ****
--- 144,150 ----
  }
  #endif /* BSD4_2 */
+ #endif /* havelocks */
  
+ #ifndef HAVELOCKS
  #ifdef VMS
  #define HAVELOCKS
***************
*** 199,202 ****
--- 204,208 ----
  }
  #endif /* VMS */
+ #endif /* havelocks */
  
  #ifndef HAVELOCKS
diff -r -c2 src.orig/D.priv/transmit.c src/D.priv/transmit.c
*** src.orig/D.priv/transmit.c	Mon Aug 28 04:28:47 1989
--- src/D.priv/transmit.c	Thu Oct  5 11:42:55 1989
***************
*** 330,333 ****
--- 330,334 ----
      }
  
+     (void) fclose(in);
      return(SUCCEED);
  }
diff -r -c2 src.orig/D.priv/wrhistory.c src/D.priv/wrhistory.c
*** src.orig/D.priv/wrhistory.c	Mon Aug 28 04:28:46 1989
--- src/D.priv/wrhistory.c	Tue Oct  3 15:57:37 1989
***************
*** 226,231 ****
  	(void) strcat(refbuf, hp->h_ident);
  
! 	this = strtok(refbuf, ", ");
! 	while (last = this, this = strtok((char *)NULL, ", "))
  	{
  	    static hdr_t	hh;
--- 226,231 ----
  	(void) strcat(refbuf, hp->h_ident);
  
! 	this = strtok(refbuf, ",	 ");
! 	while (last = this, this = strtok((char *)NULL, ", 	"))
  	{
  	    static hdr_t	hh;
diff -r -c2 src.orig/D.uucp/uuq.c src/D.uucp/uuq.c
*** src.orig/D.uucp/uuq.c	Tue Aug  1 14:12:57 1989
--- src/D.uucp/uuq.c	Wed Oct  4 15:50:27 1989
***************
*** 53,57 ****
       * system to system.
       */
!     (void) sprintf(bfr, "uuq -l -s%s", name);
  
      fp = peopen(bfr, "r");
--- 53,57 ----
       * system to system.
       */
!     (void) sprintf(bfr, "%s/uuq -l -s%s", UUBINDIR, name);
  
      fp = peopen(bfr, "r");
diff -r -c2 src.orig/control.c src/control.c
*** src.orig/control.c	Mon Aug 28 04:29:01 1989
--- src/control.c	Thu Oct  5 18:06:09 1989
***************
*** 260,263 ****
--- 260,265 ----
      }
  
+     (void) strcpy(tl, "sendme ");
+ 	
      /*
       * have the other system send over all the messages we don't have
***************
*** 269,272 ****
--- 271,275 ----
  	int	count = 0;
  
+ 	(void) strcat(tl, site.nodename);
  	(void) strcpy(rtmp, "/tmp/replyXXXXXX");
  	(void) mktemp(rtmp);
***************
*** 305,309 ****
      else	    /* else put it back in the message header */
      {
- 	(void) strcpy(tl, "sendme ");
  	for (i = 1; i < (argc - 1); i++)
  	{
--- 308,311 ----
diff -r -c2 src.orig/expire.c src/expire.c
*** src.orig/expire.c	Mon Aug 28 04:28:56 1989
--- src/expire.c	Wed Oct  4 16:35:20 1989
***************
*** 136,139 ****
--- 136,141 ----
  
      newsinit();			/* set up defaults and initialize. */
+     if (ACTIVE == (char *)NULL)
+ 	Sprint1(ACTIVE, "%s/active", site.admdir);
  #ifdef DEBUG
      if (!debug)
***************
*** 156,160 ****
  
      /* process command-line options */
-     verbose = V_SHOWSTATS;
      if (procopts(argc, argv, DNC, options) == FAIL) {
  	(void) fprintf(stderr,
--- 158,161 ----
diff -r -c2 src.orig/inews.c src/inews.c
*** src.orig/inews.c	Wed Jul 12 22:21:49 1989
--- src/inews.c	Wed Oct  4 14:06:37 1989
***************
*** 210,214 ****
  
  	/* break on an MMDF-style message delimiter */
! 	if (!tty && strncmp(inbuf, "\1\1\1\1", 4) == 0)
  	    break;
  
--- 210,214 ----
  
  	/* break on an MMDF-style message delimiter */
! 	if (!tty && lcount > 0 && strncmp(inbuf, "\1\1\1\1", 4) == 0)
  	    break;
  
***************
*** 273,276 ****
--- 273,278 ----
      long lastline = 0L;
  
+     mailfrom[0] = '\0';
+ 
      /* snarf text into a tempfile connected to stdin */
      rawfile = gettext("/tmp/inewsrawXXXXXX");
***************
*** 284,288 ****
  	{
  	    header.h_intnumlines--;
! 	    if (!strncmp(bfr, "Received: ", 13))
  		continue;
  	    else if (bfr[0] == ' ' && bfr[0] == '\t')
--- 286,290 ----
  	{
  	    header.h_intnumlines--;
! 	    if (!strncmp(bfr, "Received:", 9))
  		continue;
  	    else if (bfr[0] == ' ' && bfr[0] == '\t')
diff -r -c2 src.orig/newsdb.c src/newsdb.c
*** src.orig/newsdb.c	Mon Aug 28 17:24:57 1989
--- src/newsdb.c	Wed Oct  4 15:41:37 1989
***************
*** 927,932 ****
      else if (sscanf(cmdline, "o %s", strv) == 1)
      {
! 	if ((opt = s_option(sys, strv)) == (char *)NULL)
! 	    (void) printf("No option %s on %s\n", opt, sys->s_name);
  	else
  	    (void) printf("Option %s on %s is %s\n", strv, sys->s_name, opt);
--- 927,932 ----
      else if (sscanf(cmdline, "o %s", strv) == 1)
      {
! 	if ((opt = s_option(sys, *strv)) == (char *)NULL)
! 	    (void) printf("No option %s on %s\n", strv, sys->s_name);
  	else
  	    (void) printf("Option %s on %s is %s\n", strv, sys->s_name, opt);
diff -r -c2 src.orig/sendbatch.c src/sendbatch.c
*** src.orig/sendbatch.c	Mon Aug 28 04:28:53 1989
--- src/sendbatch.c	Wed Oct  4 16:06:30 1989
***************
*** 195,198 ****
--- 184,189 ----
  	while ((entry = readdir(directory)) != (struct dirent *)NULL)
  	{
+ 	    char *dot;
+ 
  	    /* skip . and .. and files that are supposed to be invisible */
  	    if (entry->d_name[0] == '.')
***************
*** 202,211 ****
  	    if (ngmatch(entry->d_name, sendto))
  	    {
  		if ((target = s_find(entry->d_name)) == (feed_t *)NULL)
  		    xerror1("couldn't find feed data for %s", entry->d_name);
  		else
  		    newsbatch(entry->d_name, target);
- 		if (killf)
- 		    (void) unlink(entry->d_name);
  	    }
  	}
--- 193,213 ----
  	    if (ngmatch(entry->d_name, sendto))
  	    {
+ 		if ((dot = strrchr(entry->d_name,'.')) != (char *)NULL) {
+ 		    if (!strcmp(dot,".work"))
+ 		    	*dot = '\0';
+ 		    else if (!strcmp(dot,".tmp"))
+ 			continue;
+ 		}
  		if ((target = s_find(entry->d_name)) == (feed_t *)NULL)
  		    xerror1("couldn't find feed data for %s", entry->d_name);
+ 		else if (killf) {
+ 		    (void) unlink(entry->d_name);
+ 		    if (dot) {
+ 			*dot = '.';
+ 		    	(void) unlink(entry->d_name);
+ 		    }
+ 		}
  		else
  		    newsbatch(entry->d_name, target);
  	    }
  	}
***************
*** 329,333 ****
  	cp++;
      if ((maxbytes = atol(cp)) == 0)
!         maxbytes = spoolmin;
  
      /* now transmit the contents of that batch to the target */
--- 333,337 ----
  	cp++;
      if ((maxbytes = atol(cp)) == 0)
!         maxbytes = spoolmin * 512;
  
      /* now transmit the contents of that batch to the target */
***************
*** 344,348 ****
   */
  
! private void uuxbatch(target, sp, batchfile, bytesleft)
  /* execute the commands implied by a batch file */
  char	*target;	/* target system(s) to send to */
--- 350,354 ----
   */
  
! private void uuxbatch(target, sp, batchfile, batchsize)
  /* execute the commands implied by a batch file */
  char	*target;	/* target system(s) to send to */
***************
*** 349,353 ****
  feed_t	*sp;		/* for xmit command and options */
  char	*batchfile;	/* the file */
! long	bytesleft;	/* maximum size of batch sections */
  {
      char    		linbuf[BUFLEN], *batchline, *fname, *extra = linbuf;
--- 355,359 ----
  feed_t	*sp;		/* for xmit command and options */
  char	*batchfile;	/* the file */
! long	batchsize;	/* maximum size of batch sections */
  {
      char    		linbuf[BUFLEN], *batchline, *fname, *extra = linbuf;
***************
*** 355,358 ****
--- 361,365 ----
      forward void	uuxfile();
      int			goodsends;
+     long		bytesleft;
  
      /* if we're just sending an ihave list, do that and exit */
***************
*** 368,371 ****
--- 375,379 ----
  
      do {
+ 	bytesleft = batchsize;
  #ifdef DEBUG
  	if (debug)	    /* so we can test without news permissions */
***************
*** 539,545 ****
  	    (void) write(ofd, UNBATCH, sizeof(UNBATCH) - 1);
  	else if (s_option(sp, 'E'))
- 	    (void) write(ofd, CUNBATCH, sizeof(CUNBATCH) - 1);
- 	else
  	    (void) write(ofd, C7UNBATCH, sizeof(C7UNBATCH) - 1);
      
      /* now copy the rest of the batch to the transmission file */
--- 553,559 ----
  	    (void) write(ofd, UNBATCH, sizeof(UNBATCH) - 1);
  	else if (s_option(sp, 'E'))
  	    (void) write(ofd, C7UNBATCH, sizeof(C7UNBATCH) - 1);
+ 	else
+ 	    (void) write(ofd, CUNBATCH, sizeof(CUNBATCH) - 1);
      
      /* now copy the rest of the batch to the transmission file */

-- 
Matthias Urlichs
urlichs@smurf.ira.uka.de

urlichs@iraun1.ira.uka.de (Matthias Urlichs) (10/08/89)

In article <1T2Ds0#1Brt55=urlichs@iraun1.ira.uka.de> urlichs@ira.uka.de (Matthias Urlichs) writes:
< These diffs to tmnn 7.8 fix some major bugs.
< Expire should run now. :-)
< 
But everything else didn't.
Right now I'm back to 2.11. :-(

The last straw was rnews -U hanging on me. I killed it; rnews processed the
rest of the current batch and quit. Fine. Not very nice, but fine.
Then I started rnews -U again. It hung. I tried to kill it -- no reaction.
I sent it a SIGHUP -- processing rest of batcxh and quitting. Fine.
Then I started rnews -U again. It hung again (after some time).
kill didn't do anything. Kill -HUP didn't work. kill -TERM killed it
(behavior as above).  I would be very interested in how to achieve
that kind of behavior on one of my programs. ;-)

Actually, I guess I should apologize for the sorry state of the pathes 
I posted. (I tried to cancel the article; I hope it got through.)
However, I already mailed them to erik@snark.uu.net and didn't get a reply...