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. */
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to