From owner-svn-src-head@freebsd.org Thu Jan 12 21:18:45 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 062FDCAC5A6; Thu, 12 Jan 2017 21:18:45 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CA173143C; Thu, 12 Jan 2017 21:18:44 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v0CLIh3w070476; Thu, 12 Jan 2017 21:18:43 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v0CLIhVN070475; Thu, 12 Jan 2017 21:18:43 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201701122118.v0CLIhVN070475@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Thu, 12 Jan 2017 21:18:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r311996 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jan 2017 21:18:45 -0000 Author: ian Date: Thu Jan 12 21:18:43 2017 New Revision: 311996 URL: https://svnweb.freebsd.org/changeset/base/311996 Log: Restructure the tty_drain loop so that device-busy is checked one more time after tty_timedwait() returns an error only if the error is EWOULDBLOCK; other errors cause an immediate return. This fixes the case of the tty disappearing while in tty_drain(). Reported by: pho Modified: head/sys/kern/tty.c Modified: head/sys/kern/tty.c ============================================================================== --- head/sys/kern/tty.c Thu Jan 12 20:26:02 2017 (r311995) +++ head/sys/kern/tty.c Thu Jan 12 21:18:43 2017 (r311996) @@ -166,11 +166,9 @@ tty_drain(struct tty *tp, int leaving) return (error); ttydevsw_outwakeup(tp); error = tty_timedwait(tp, &tp->t_outwait, hz / 10); - if (timeout_at == 0 && error == EWOULDBLOCK) - error = 0; - if (error != EWOULDBLOCK) - continue; - if (getsbinuptime() < timeout_at) + if (error != 0 && error != EWOULDBLOCK) + return (error); + else if (timeout_at == 0 || getsbinuptime() < timeout_at) error = 0; else if (leaving && ttyoutq_bytesused(&tp->t_outq) < bytes) { /* In close, making progress, grant an extra second. */