From toasty@shell1.dragondata.com  Thu Dec 24 17:29:14 1998
Received: from shell1.dragondata.com (shell1.dragondata.com [204.137.237.8])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id RAA17108
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 24 Dec 1998 17:29:13 -0800 (PST)
          (envelope-from toasty@shell1.dragondata.com)
Received: (from root@localhost)
	by shell1.dragondata.com (8.8.8/8.8.8) id TAA20397;
	Thu, 24 Dec 1998 19:28:57 -0600 (CST)
	(envelope-from toasty)
Message-Id: <199812250128.TAA20397@shell1.dragondata.com>
Date: Thu, 24 Dec 1998 19:28:57 -0600 (CST)
From: toasty@dragondata.com
Reply-To: toasty@dragondata.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: telnet gets stuck in ttydrain()
X-Send-Pr-Version: 3.2

>Number:         9188
>Category:       bin
>Synopsis:       telnet gets stuck in ttydrain()
>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:   Thu Dec 24 17:30:00 PST 1998
>Closed-Date:    Sat Jan 19 15:12:50 PST 2002
>Last-Modified:  Sat Jan 19 15:13:36 PST 2002
>Originator:     Kevin Day
>Release:        FreeBSD 3.0-RELEASE i386
>Organization:
DragonData Internet Services, Inc.
>Environment:

3.0-RELEASE system

>Description:

I found a telnet process sucking 100% cpu, after a user reported it.

ktracing it showed:


 11573 telnet   CALL  write(0x1,0x8058c20,0x174)
 11573 telnet   RET   write -1 errno 5 Input/output error
 11573 telnet   CALL  ioctl(0,TIOCSETAW,0xefbfd8c8)
 11573 telnet   RET   ioctl -1 errno 9 Bad file descriptor
 11573 telnet   CALL  write(0x1,0x8058c20,0x174)
 11573 telnet   RET   write -1 errno 5 Input/output error
 11573 telnet   CALL  ioctl(0,TIOCSETAW,0xefbfd8c8)
 11573 telnet   RET   ioctl -1 errno 9 Bad file descriptor
 11573 telnet   CALL  write(0x1,0x8058c20,0x174)
 11573 telnet   RET   write -1 errno 5 Input/output error
 11573 telnet   CALL  ioctl(0,TIOCSETAW,0xefbfd8c8)
 11573 telnet   RET   ioctl -1 errno 9 Bad file descriptor

Which appears to be in sys_bsd.c:ttydrain

Perhaps that while loop should check for fatal errors rather than retrying
everything? Or is this a case that it should never have gotten this far with
the FD being closed?

The user, without waiting for me, killed the process, so I wasn't able
to get any more debugging.

>How-To-Repeat:

>Fix:
	

>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: FreeBSD-gnats-submit@FreeBSD.ORG, toasty@dragondata.com
Cc:  Subject: Re: bin/9188: telnet gets stuck in ttydrain()
Date: Fri, 25 Dec 1998 21:04:54 +1100

 > 11573 telnet   CALL  write(0x1,0x8058c20,0x174)
 > 11573 telnet   RET   write -1 errno 5 Input/output error
 > 11573 telnet   CALL  ioctl(0,TIOCSETAW,0xefbfd8c8)
 > 11573 telnet   RET   ioctl -1 errno 9 Bad file descriptor
 > 11573 telnet   CALL  write(0x1,0x8058c20,0x174)
 > 11573 telnet   RET   write -1 errno 5 Input/output error
 > 11573 telnet   CALL  ioctl(0,TIOCSETAW,0xefbfd8c8)
 > 11573 telnet   RET   ioctl -1 errno 9 Bad file descriptor
 > 11573 telnet   CALL  write(0x1,0x8058c20,0x174)
 > 11573 telnet   RET   write -1 errno 5 Input/output error
 > 11573 telnet   CALL  ioctl(0,TIOCSETAW,0xefbfd8c8)
 > 11573 telnet   RET   ioctl -1 errno 9 Bad file descriptor
 >
 >Which appears to be in sys_bsd.c:ttydrain
 >
 >Perhaps that while loop should check for fatal errors rather than retrying
 >everything? Or is this a case that it should never have gotten this far with
 >the FD being closed?
 
 The tty appears to be revoked, not closed.  write() would set errno
 to EBADF if the FD were closed.  ioctl() shouldn't return EBADF for
 open revoked FDs, but it was broken until a month or two after 3.0R.
 Now it returns ENOTTY.  This won't help telnet.
 
 The loop seems to be actually in sys_bsd.c:TerminalNewMode.  ttydrain
 doesn't exist.
 
 Telnet shouldn't retry after an error unless it knows that this is OK
 (perhaps it is OK for EAGAIN).
 
 Bruce
State-Changed-From-To: open->feedback 
State-Changed-By: iedowse 
State-Changed-When: Sat Jan 19 14:49:13 PST 2002 
State-Changed-Why:  

Does this problem still exist in more recent releases? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=9188 
State-Changed-From-To: feedback->closed 
State-Changed-By: iedowse 
State-Changed-When: Sat Jan 19 15:12:50 PST 2002 
State-Changed-Why:  

Submitter has not seen the problem on more recent releases. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=9188 
>Unformatted:
