From owner-p4-projects@FreeBSD.ORG Wed Sep 24 11:49:41 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C01F11065679; Wed, 24 Sep 2008 11:49:40 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 835EC106566C for ; Wed, 24 Sep 2008 11:49:40 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 743968FC28 for ; Wed, 24 Sep 2008 11:49:40 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id m8OBne8m044967 for ; Wed, 24 Sep 2008 11:49:40 GMT (envelope-from ed@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id m8OBneIC044965 for perforce@freebsd.org; Wed, 24 Sep 2008 11:49:40 GMT (envelope-from ed@FreeBSD.org) Date: Wed, 24 Sep 2008 11:49:40 GMT Message-Id: <200809241149.m8OBneIC044965@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to ed@FreeBSD.org using -f From: Ed Schouten To: Perforce Change Reviews Cc: Subject: PERFORCE change 150382 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Sep 2008 11:49:41 -0000 http://perforce.freebsd.org/chv.cgi?CH=150382 Change 150382 by ed@ed_dull on 2008/09/24 11:49:24 - Don't call ttydev_leave() when tty_unlock() is good enough. - Correct error codes of read() and write() calls. Affected files ... .. //depot/projects/mpsafetty/sys/kern/tty.c#44 edit Differences ... ==== //depot/projects/mpsafetty/sys/kern/tty.c#44 (text+ko) ==== @@ -133,11 +133,12 @@ } /* - * Because the revoke() call already calls d_close() without making sure - * all threads are purged from the TTY, we can only destroy the buffers - * and such when the last thread leaves the TTY. ttydev_enter() and - * ttydev_leave() are called from within the cdev functions, to make - * sure we can garbage collect the TTY. + * Though ttydev_enter() and ttydev_leave() seem to be related, they + * don't have to be used together. ttydev_enter() is used by the cdev + * operations to prevent an actual from being processed when the TTY has + * been abandoned. ttydev_leave() is used by ttydev_open() and + * ttydev_close() to determine whether per-TTY data should be + * deallocated. */ static __inline int @@ -287,6 +288,7 @@ done: tp->t_flags &= ~TF_OPENCLOSE; ttydev_leave(tp); + return (error); } @@ -378,22 +380,23 @@ error = ttydev_enter(tp); if (error) - return (0); + goto done; error = tty_wait_background(tp, curthread, SIGTTIN); - if (error) + if (error) { + tty_unlock(tp); goto done; + } error = ttydisc_read(tp, uio, ioflag); -done: ttydev_leave(tp); + tty_unlock(tp); /* - * The read() and write() calls should not throw an error when - * the device is ripped offline. + * The read() call should not throw an error when the device is + * being destroyed. Silently convert it to an EOF. */ - if (error == ENXIO) - return (0); - +done: if (error == ENXIO) + error = 0; return (error); } @@ -405,24 +408,19 @@ error = ttydev_enter(tp); if (error) - return (0); + return (error); if (tp->t_termios.c_lflag & TOSTOP) { error = tty_wait_background(tp, curthread, SIGTTOU); - if (error) - goto done; + if (error) { + tty_unlock(tp); + return (error); + } } error = ttydisc_write(tp, uio, ioflag); -done: ttydev_leave(tp); + tty_unlock(tp); - /* - * The read() and write() calls should not throw an error when - * the device is ripped offline. - */ - if (error == ENXIO) - return (0); - return (error); } @@ -479,7 +477,7 @@ } error = tty_ioctl(tp, cmd, data, td); -done: ttydev_leave(tp); +done: tty_unlock(tp); return (error); } @@ -518,7 +516,7 @@ selrecord(td, &tp->t_outpoll); } - ttydev_leave(tp); + tty_unlock(tp); return (revents); } @@ -535,7 +533,7 @@ if (error) return (-1); error = ttydevsw_mmap(tp, offset, paddr, nprot); - ttydev_leave(tp); + tty_unlock(tp); return (error); } @@ -623,7 +621,7 @@ break; } - ttydev_leave(tp); + tty_unlock(tp); return (error); }