Date: Sun, 2 Aug 2009 14:31:08 +0200 From: Ed Schouten <ed@80386.nl> To: Kostik Belousov <kostikbel@gmail.com> Cc: FreeBSD Current <current@freebsd.org> Subject: Re: HEAD tty seems to drop characters Message-ID: <20090802123108.GY1292@hoeg.nl> In-Reply-To: <20090802105033.GG1884@deviant.kiev.zoral.com.ua> References: <20090802105033.GG1884@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
--tzjrJU3+iJ6c5SNx Content-Type: multipart/mixed; boundary="UsiV5d7KlsBC0zIw" Content-Disposition: inline --UsiV5d7KlsBC0zIw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Kostik, * Kostik Belousov <kostikbel@gmail.com> wrote: > I run a screen(1), where I tried to copy large portion of output and > paste it into vi. This resulted in the loss of the characters at random > points inside the pasted text. I already took some time to investigate the issue. I have attached a patch that should already improve the situation: - write() on a pseudo-terminal master also accounted the data that was read into the kernel, but couldn't be passed to the TTY (which is likely to happen in non-blocking mode). - There was also a small unrelated issue; input on a TTY which has been configured in block (bypass) mode wouldn't set the input high water mark. For some reason, the data loss doesn't occur when SSHing to myself multiple times, but still causes screen(1) to drop some bytes later on. Even though it's always very easy to blame other applications, I suspect this may be because I reduced the input buffer size from 8 KB to 2 KB per pseudo-terminal. Maybe screen(1) can't deal with this. To be investigated... --=20 Ed Schouten <ed@80386.nl> WWW: http://80386.nl/ --UsiV5d7KlsBC0zIw Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pts-dataloss.diff" Content-Transfer-Encoding: quoted-printable Index: tty_pts.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- tty_pts.c (revision 195892) +++ tty_pts.c (working copy) @@ -204,8 +204,10 @@ error =3D uiomove(ib, iblen, uio); =20 tty_lock(tp); - if (error !=3D 0) + if (error !=3D 0) { + iblen =3D 0; goto done; + } =20 /* * When possible, avoid the slow path. rint_bypass() @@ -260,6 +262,12 @@ =20 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 +=3D iblen; return (error); } =20 Index: tty_ttydisc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- tty_ttydisc.c (revision 195892) +++ tty_ttydisc.c (working copy) @@ -1060,6 +1060,8 @@ =20 ret =3D ttyinq_write(&tp->t_inq, buf, len, 0); ttyinq_canonicalize(&tp->t_inq); + if (ret < len) + tty_hiwat_in_block(tp); =20 return (ret); } --UsiV5d7KlsBC0zIw-- --tzjrJU3+iJ6c5SNx Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkp1hwwACgkQ52SDGA2eCwUwwACePc3FmwkI+FDrJV67Nk3wjspi 63YAn2hzX913jKDbfWLDw9ykEcSojjn/ =XoEk -----END PGP SIGNATURE----- --tzjrJU3+iJ6c5SNx--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090802123108.GY1292>