From dillon@flea.best.net  Wed Aug 13 17:28:33 1997
Received: from flea.best.net (root@flea.best.net [206.184.139.131])
          by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id RAA10033
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 13 Aug 1997 17:28:32 -0700 (PDT)
Received: (from dillon@localhost) by flea.best.net (8.8.6/8.8.3) id RAA27163; Wed, 13 Aug 1997 17:27:54 -0700 (PDT)
Message-Id: <199708140027.RAA27163@flea.best.net>
Date: Wed, 13 Aug 1997 17:27:54 -0700 (PDT)
From: Matt Dillon <dillon@best.net>
Reply-To: dillon@best.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: bug in lpt driver
X-Send-Pr-Version: 3.2

>Number:         4300
>Category:       i386
>Synopsis:       The initial timeout on open("/dev/lpt0"...) is too small
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 13 17:30:00 PDT 1997
>Closed-Date:    Tue Aug 31 03:28:49 GMT 2004
>Last-Modified:  Tue Aug 31 03:28:49 GMT 2004
>Originator:     Matt Dillon
>Release:        FreeBSD 2.2-STABLE i386
>Organization:
BEST Internet
>Environment:

>Description:

	When using /dev/lpt0 directly from programs or shell scripts that
	send multiple pages to the printer as separate transactions 
	(open, write a few pages, close, open, write a few pages, close),
	printers with large internal buffers (read: nearly all laser printers)
	may hold the printer in a non-ready state for long periods of
	time while draining the buffer.  If an open() attempt is made
	in this case, the 4 second timeout is insufficient and we have
	found that the open fails several times an hour, causing our scripts
	to abort.

	The problem occurs even more often when the printer runs out of
	paper.  If the operator is unable to load new paper into the printer
	fast enough, opens of /dev/lpt0 begin to fail.   Since many printers
	are left alone for long periods of time, my suggestion is that there
	be NO ready timeout whatsoever in the lpt driver.  Instead, check for
	an ERROR condition on open.

	Since there is nothing wrong with the printer, I consider the failure
	a bug.

>How-To-Repeat:

	

>Fix:
	
	The fix is to not have an LP ready timeout in the open().  In
	/usr/src/sys/i386/isa/lpt.c, around line 530, #ifdef out
	the code as shown below.  I suggest making the default be 
	NO timeout, and have an option to force a timeout.

	It should also be noted that since the open() is interruptable,
	removing the timeout should not have any effect on the ability
	of the operator to kill off blocked processes in the case where
	the printer truely has a problem.



        trys = 0;
        do {
                /* ran out of waiting for the printer */
#ifdef DOLPTIMEOUT		/* ADD THIS */
                if (trys++ >= LPINITRDY*4) {
                        splx(s);
                        sc->sc_state = 0;
                        lprintf ("status %x\n", inb(port+lpt_status) );
                        return (EBUSY);
                }
#endif				/* ADD THIS */

                /* wait 1/4 second, give up if we get a signal */
                if (tsleep ((caddr_t)sc, LPPRI|PCATCH, "lptinit", hz/4) !=
                    EWOULDBLOCK) {
                        sc->sc_state = 0;





>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->msmith 
Responsible-Changed-By: msmith 
Responsible-Changed-When: Sun Aug 17 02:48:12 PDT 1997 
Responsible-Changed-Why:  
lpt blood is on my hands right now. 

From: Eric Anderson <anderson@centtech.com>
To: freebsd-gnats-submit@FreeBSD.org, dillon@best.net
Cc:  
Subject: Re: i386/4300: The initial timeout on open("/dev/lpt0"...) is too
 small
Date: Mon, 31 Mar 2003 07:54:38 -0600

 What ever happened with this? It's so old I assume this PR can be closed..
 
 Eric
 
 
 -- 
 ------------------------------------------------------------------
 Eric Anderson	   Systems Administrator      Centaur Technology
 The moon may be smaller than Earth, but it's further away.
 ------------------------------------------------------------------
 
State-Changed-From-To: open->feedback 
State-Changed-By: linimon 
State-Changed-When: Thu Aug 26 02:47:30 GMT 2004 
State-Changed-Why:  
Is this still a problem with modern versions of FreeBSD? 


Responsible-Changed-From-To: msmith->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu Aug 26 02:47:30 GMT 2004 
Responsible-Changed-Why:  
With bugmeister hat on, reassign from inactive committer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=4300 
State-Changed-From-To: feedback->closed 
State-Changed-By: linimon 
State-Changed-When: Tue Aug 31 03:27:19 GMT 2004 
State-Changed-Why:  
There was never any feedback on this, and neither the submitter 
nor the assignee are actively involved in FreeBSD at this time. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=4300 
>Unformatted:
