From owner-taylor-uucp@gnu.ai.mit.edu Wed Apr 15 00:05:51 1992
Status: RO
X-VM-v5-Data: ([nil nil nil nil nil nil nil nil nil]
	[nil nil nil nil nil nil nil nil nil nil nil nil "^From:" nil nil nil])
Received: from fuug.fi by dolphin.funet.fi with SMTP id AA06888
  (5.65c/IDA-1.4.3 for ojala); Wed, 15 Apr 1992 00:05:43 +0300
Received: from funet.fi by fuug.fi with SMTP id AA17110
  (5.65c/IDA-1.4.4 for <taylor-uucp-list@fuug.fi>); Wed, 15 Apr 1992 00:03:04 +0300
Received: from churchy.gnu.ai.mit.edu by funet.fi with SMTP (PP) 
          id <01623-0@funet.fi>; Wed, 15 Apr 1992 00:05:21 +0300
Received: by churchy.gnu.ai.mit.edu (5.65/4.0) 
          id <AA08235@churchy.gnu.ai.mit.edu>; Tue, 14 Apr 92 16:06:44 -0400
Received: from relay2.UU.NET by churchy.gnu.ai.mit.edu (5.65/4.0) with SMTP 
          id <AA08229@churchy.gnu.ai.mit.edu>; Tue, 14 Apr 92 16:06:38 -0400
Received: from uunet.uu.net (via LOCALHOST.UU.NET) by relay2.UU.NET 
          with SMTP (5.61/UUNET-internet-primary) id AA26014;
          Tue, 14 Apr 92 16:06:43 -0400
Received: from airs.UUCP by uunet.uu.net with UUCP/RMAIL (queueing-rmail) 
          id 160531.12993; Tue, 14 Apr 1992 16:05:31 EDT
Received: by comton.airs.com (5.57/AIRS1.0) id AA15954;
          Tue, 14 Apr 92 15:07:27 -0400
Message-Id: <9204141907.AA15954@comton.airs.com>
In-Reply-To: <m0lactF-0000knC@s4mjs.uucp>; from "M.J.Shannon" at Apr 13, 92 10:04 pm
X-Mailer: ELM [version 2.3 PL11]
From: ian@airs.com (Ian Lance Taylor)
To: s4mjs!mjs@westmark.westmark.com (M.J.Shannon)
Cc: taylor-uucp@gnu.ai.mit.edu, jarmo@ksvltd.fi
Subject: Re: Bug in fsysdep_get_work as used by uustat
Date: Tue, 14 Apr 92 15:07:26 -0400

Marty Shannon writes:

> When uustat -q is invoked, it eventually calls fsysdep_get_work(),
> which will remove any empty C. files.

Here is an unofficial patch which should fix this problem.

*** 1.32	1992/03/17 03:15:40
--- system.h	1992/04/14 18:46:50
***************
*** 345,367 ****
  /* Initialize the work scan.  This will be called before
     fsysdep_get_work.  The bgrade argument is the minimum grade of
     execution files that should be considered (e.g. a bgrade of 'd'
!    will allow all grades from 'A' to 'Z' and 'a' to 'd').  It should
!    return FALSE on error.  */
  extern boolean fsysdep_get_work_init P((const struct ssysteminfo *qsys,
! 					int bgrade));
  
  /* Get the next command to be executed for a remote system.  The
!    bgrade argument will be the same as for fsysdep_get_work_init;
!    probably only one of these functions will use it, namely the
!    function for which it is more convenient.  This should return FALSE
!    on error.  The structure pointed to by qcmd should be filled in.
!    The strings may point into a static buffer; they will be copied out
!    if necessary.  If there is no more work, this should set qcmd->bcmd
!    to 'H' and return TRUE.  This should set qcmd->pseq to something
!    which can be passed to fsysdep_did_work to remove the job from the
!    queue when it has been completed.  */
  extern boolean fsysdep_get_work P((const struct ssysteminfo *qsys,
! 				   int bgrade, struct scmd *qcmd));
  
  /* Remove a job from the work queue.  This must also remove the
     temporary file used for a send command, if there is one.  It should
--- 345,371 ----
  /* Initialize the work scan.  This will be called before
     fsysdep_get_work.  The bgrade argument is the minimum grade of
     execution files that should be considered (e.g. a bgrade of 'd'
!    will allow all grades from 'A' to 'Z' and 'a' to 'd').  The fcheck
!    argument is TRUE if the work will not actually be done (i.e. this
!    is being called by uustat).  This function should return FALSE on
!    error.  */
  extern boolean fsysdep_get_work_init P((const struct ssysteminfo *qsys,
! 					int bgrade, boolean fcheck));
  
  /* Get the next command to be executed for a remote system.  The
!    bgrade and fcheck arguments will be the same as for
!    fsysdep_get_work_init; probably only one of these functions will
!    use them, namely the function for which it is more convenient.
!    This should return FALSE on error.  The structure pointed to by
!    qcmd should be filled in.  The strings may point into a static
!    buffer; they will be copied out if necessary.  If there is no more
!    work, this should set qcmd->bcmd to 'H' and return TRUE.  This
!    should set qcmd->pseq to something which can be passed to
!    fsysdep_did_work to remove the job from the queue when it has been
!    completed.  */
  extern boolean fsysdep_get_work P((const struct ssysteminfo *qsys,
! 				   int bgrade, boolean fcheck,
! 				   struct scmd *qcmd));
  
  /* Remove a job from the work queue.  This must also remove the
     temporary file used for a send command, if there is one.  It should
*** 1.92	1992/04/06 21:10:14
--- uucico.c	1992/04/14 18:48:51
***************
*** 2270,2276 ****
      fnowork = TRUE;
    else
      {
!       if (! fsysdep_get_work_init (qsys, bgrade))
  	return FALSE;
        fnowork = FALSE;
      }
--- 2270,2276 ----
      fnowork = TRUE;
    else
      {
!       if (! fsysdep_get_work_init (qsys, bgrade, FALSE))
  	return FALSE;
        fnowork = FALSE;
      }
***************
*** 2336,2342 ****
  	  else
  	    {
  	      s.zuser = NULL;
! 	      if (! fsysdep_get_work (qsys, bgrade, &s))
  		return FALSE;
  	      ulog_user (s.zuser);
  	    }
--- 2336,2342 ----
  	  else
  	    {
  	      s.zuser = NULL;
! 	      if (! fsysdep_get_work (qsys, bgrade, FALSE, &s))
  		return FALSE;
  	      ulog_user (s.zuser);
  	    }
***************
*** 2911,2917 ****
  		{
  		  if (fmasterdone)
  		    {
! 		      if (! fsysdep_get_work_init (qsys, bgrade))
  			return FALSE;
  		      fnowork = FALSE;
  		    }
--- 2911,2917 ----
  		{
  		  if (fmasterdone)
  		    {
! 		      if (! fsysdep_get_work_init (qsys, bgrade, FALSE))
  			return FALSE;
  		      fnowork = FALSE;
  		    }
*** 1.7	1992/03/28 22:54:45
--- uustat.c	1992/04/14 18:49:10
***************
*** 436,442 ****
  {
    boolean fret;
  
!   if (! fsysdep_get_work_init (qsys, BGRADE_LOW))
      return FALSE;
  
    while (TRUE)
--- 436,442 ----
  {
    boolean fret;
  
!   if (! fsysdep_get_work_init (qsys, BGRADE_LOW, TRUE))
      return FALSE;
  
    while (TRUE)
***************
*** 444,450 ****
        struct scmd s;
        long itime;
  
!       if (! fsysdep_get_work (qsys, BGRADE_LOW, &s))
  	{
  	  usysdep_get_work_free (qsys);
  	  return FALSE;
--- 444,450 ----
        struct scmd s;
        long itime;
  
!       if (! fsysdep_get_work (qsys, BGRADE_LOW, TRUE, &s))
  	{
  	  usysdep_get_work_free (qsys);
  	  return FALSE;
***************
*** 874,880 ****
    long ifirstwork;
    boolean fret;
  
!   if (! fsysdep_get_work_init (qsys, BGRADE_LOW))
      return FALSE;
  
    cwork = 0;
--- 874,880 ----
    long ifirstwork;
    boolean fret;
  
!   if (! fsysdep_get_work_init (qsys, BGRADE_LOW, TRUE))
      return FALSE;
  
    cwork = 0;
***************
*** 884,890 ****
        struct scmd s;
        long itime;
  
!       if (! fsysdep_get_work (qsys, BGRADE_LOW, &s))
  	return FALSE;
        if (s.bcmd == 'H')
  	break;
--- 884,890 ----
        struct scmd s;
        long itime;
  
!       if (! fsysdep_get_work (qsys, BGRADE_LOW, TRUE, &s))
  	return FALSE;
        if (s.bcmd == 'H')
  	break;
*** 1.17	1992/03/12 19:56:10
--- sys4.unx	1992/04/14 18:55:15
***************
*** 342,350 ****
  
  /*ARGSUSED*/
  boolean
! fsysdep_get_work_init (qsys, bgrade)
       const struct ssysteminfo *qsys;
       int bgrade;
  {
    const char *zdir;
    DIR *qdir;
--- 342,351 ----
  
  /*ARGSUSED*/
  boolean
! fsysdep_get_work_init (qsys, bgrade, fcheck)
       const struct ssysteminfo *qsys;
       int bgrade;
+      boolean fcheck;
  {
    const char *zdir;
    DIR *qdir;
***************
*** 432,440 ****
     calling fsysdep_get_work_init to rescan.  */
  
  boolean
! fsysdep_get_work (qsys, bgrade, qcmd)
       const struct ssysteminfo *qsys;
       int bgrade;
       struct scmd *qcmd;
  {
    const char *zdir;
--- 433,442 ----
     calling fsysdep_get_work_init to rescan.  */
  
  boolean
! fsysdep_get_work (qsys, bgrade, fcheck, qcmd)
       const struct ssysteminfo *qsys;
       int bgrade;
+      boolean fcheck;
       struct scmd *qcmd;
  {
    const char *zdir;
***************
*** 469,475 ****
  	      if (iSwork_file >= cSwork_files)
  		{
  		  /* Rescan the work directory.  */
! 		  if (! fsysdep_get_work_init (qsys, bgrade))
  		    return FALSE;
  		  if (iSwork_file >= cSwork_files)
  		    {
--- 471,477 ----
  	      if (iSwork_file >= cSwork_files)
  		{
  		  /* Rescan the work directory.  */
! 		  if (! fsysdep_get_work_init (qsys, bgrade, fcheck))
  		    return FALSE;
  		  if (iSwork_file >= cSwork_files)
  		    {
***************
*** 532,540 ****
  	      /* There was nothing in the file; remove it and look
  		 for the next one.  */
  	      xfree ((pointer) qfile);
! 	      if (remove (zname) != 0)
! 		ulog (LOG_ERROR, "remove (%s): %s", zname,
! 		      strerror (errno));
  	    }
  	  else
  	    {
--- 534,545 ----
  	      /* There was nothing in the file; remove it and look
  		 for the next one.  */
  	      xfree ((pointer) qfile);
! 	      if (! fcheck)
! 		{
! 		  if (remove (zname) != 0)
! 		    ulog (LOG_ERROR, "remove (%s): %s", zname,
! 			  strerror (errno));
! 		}
  	    }
  	  else
  	    {

-- 
Ian Taylor                     ian@airs.com                    uunet!airs!ian
First person to identify this quote wins a free e-mail message:
``Do you make a grievance of weighing so many pounds only, instead of three
  hundred?  Then why fret about living so many years only, instead of more?''

