a summary of bugs in lpd.c on 4.1

utzoo!decvax!genradbo!linus!smk utzoo!decvax!genradbo!linus!smk
Wed Dec 29 18:06:12 AEST 1982


	I found another bug in lpd.c.  There is an exit that doesn't
first remove the LOCK file.  Here is my diff to lpd.c that I have so
far.  Any other fixes you may have as far as the printer locking up?
I'd like to hear of them.  I'll post these to the net later if they
aren't complete rewrites of lpr/lpd/lpf/...

*** lpd.c.orig	Thu Jul  2 06:18:02 1981
--- lpd.c	Wed Dec 29 18:04:40 1982
***************
*** 82,87
  		ptr = top;
  		top->next = top;
  		if ( (fp = fopen(SPOOL_DIR,"r")) == NULL )
  			exit(1);
  		while (fread(&dbuf, sizeof dbuf, 1, fp) == 1) 
  		{

--- 82,91 -----
  		ptr = top;
  		top->next = top;
  		if ( (fp = fopen(SPOOL_DIR,"r")) == NULL )
+ #ifdef MITRE
+ 		{
+ 		/*	Don't forget to remove LOCK any time we exit.	*/
+ 			unlink (LOCK);
  			exit(1);
  		}
  #else
***************
*** 83,88
  		top->next = top;
  		if ( (fp = fopen(SPOOL_DIR,"r")) == NULL )
  			exit(1);
  		while (fread(&dbuf, sizeof dbuf, 1, fp) == 1) 
  		{
  			if (dbuf.d_ino==0 || dbuf.d_name[0]!='d' || dbuf.d_name[1]!='f')

--- 87,96 -----
  		/*	Don't forget to remove LOCK any time we exit.	*/
  			unlink (LOCK);
  			exit(1);
+ 		}
+ #else
+ 			exit(1);
+ #endif
  		while (fread(&dbuf, sizeof dbuf, 1, fp) == 1) 
  		{
  			if (dbuf.d_ino==0 || dbuf.d_name[0]!='d' || dbuf.d_name[1]!='f')
***************
*** 111,116
  	ptr = top;
  	top = top->next;
  	cfree(ptr);
  	return(sp);
  }
  

--- 119,128 -----
  	ptr = top;
  	top = top->next;
  	cfree(ptr);
+ #ifdef MITRE
+ 	/*	Forgot to close the spool directory.	*/
+ 	(void) fclose (fp);
+ #endif
  	return(sp);
  }
  
***************
*** 159,164
  		continue;
  
  	case 'F':
  		if (send())
  			return(1);
  		continue;

--- 171,186 -----
  		continue;
  
  	case 'F':
+ #ifdef MITRE
+ 		/*	We must close the open file when the printer
+ 			goes off-line, or pretty soon (after 15 attempts
+ 			to retry) the file limit is exceeded and the
+ 			lock doesn't go away.	*/
+ 		if (send())	{
+ 			(void) fclose(dfb);
+ 			return(1);
+ 		}
+ #else
  		if (send())
  			return(1);
  #endif
***************
*** 161,166
  	case 'F':
  		if (send())
  			return(1);
  		continue;
  
  	case 'U':

--- 183,189 -----
  #else
  		if (send())
  			return(1);
+ #endif
  		continue;
  
  	case 'U':



More information about the Comp.bugs.4bsd.ucb-fixes mailing list