Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Jan 2017 21:18:43 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r311996 - head/sys/kern
Message-ID:  <201701122118.v0CLIhVN070475@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701122118.v0CLIhVN070475>