From owner-svn-src-head@FreeBSD.ORG Sun Aug 2 14:25:27 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0E25E1065670; Sun, 2 Aug 2009 14:25:27 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F0FBC8FC08; Sun, 2 Aug 2009 14:25:26 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n72EPQ4Q016874; Sun, 2 Aug 2009 14:25:26 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n72EPQ8T016871; Sun, 2 Aug 2009 14:25:26 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200908021425.n72EPQ8T016871@svn.freebsd.org> From: Ed Schouten Date: Sun, 2 Aug 2009 14:25:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196036 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Sun, 02 Aug 2009 14:25:27 -0000 Author: ed Date: Sun Aug 2 14:25:26 2009 New Revision: 196036 URL: http://svn.freebsd.org/changeset/base/196036 Log: Fix two bugs related to TTY input: - fix write() on pseudo-terminal masters to return the amount of bytes passed to the TTY, not the amount of bytes read from user. - fix ttydisc_rint_bypass() to set the high watermark when it cannot write all input, just like ttydisc_rint() itself. Approved by: re (kib) Modified: head/sys/kern/tty_pts.c head/sys/kern/tty_ttydisc.c Modified: head/sys/kern/tty_pts.c ============================================================================== --- head/sys/kern/tty_pts.c Sun Aug 2 13:37:00 2009 (r196035) +++ head/sys/kern/tty_pts.c Sun Aug 2 14:25:26 2009 (r196036) @@ -204,8 +204,10 @@ ptsdev_write(struct file *fp, struct uio error = uiomove(ib, iblen, uio); tty_lock(tp); - if (error != 0) + if (error != 0) { + iblen = 0; goto done; + } /* * When possible, avoid the slow path. rint_bypass() @@ -260,6 +262,12 @@ ptsdev_write(struct file *fp, struct uio done: ttydisc_rint_done(tp); tty_unlock(tp); + + /* + * Don't account for the part of the buffer that we couldn't + * pass to the TTY. + */ + uio->uio_resid += iblen; return (error); } Modified: head/sys/kern/tty_ttydisc.c ============================================================================== --- head/sys/kern/tty_ttydisc.c Sun Aug 2 13:37:00 2009 (r196035) +++ head/sys/kern/tty_ttydisc.c Sun Aug 2 14:25:26 2009 (r196036) @@ -1060,6 +1060,8 @@ ttydisc_rint_bypass(struct tty *tp, cons ret = ttyinq_write(&tp->t_inq, buf, len, 0); ttyinq_canonicalize(&tp->t_inq); + if (ret < len) + tty_hiwat_in_block(tp); return (ret); }