Re: Pty is losing bytes

Roman Zippel
2005-02-16T03:12:52Z

Hi,

On Tue, 15 Feb 2005, Linus Torvalds wrote:

> > I've also seen more than one byte missing. For example when sending a big
> > chunk of bytes down the pty via an Emacs *shell* buffer up to 16 bytes are
> > missing somewhere in the middle.
>
> If it's NTTY (and I'm pretty certain it is - the generic tty code looks
> fine, the pty code itself is too simple for words), then I'd actually have
> expected more variability than a simple off-by-one.

The patch below seems to do the trick too.
It seems the initial receive_room() call in pty_write() returns
N_TTY_BUF_SIZE and receive_buf() will happily drop the last byte.

bye, Roman

n_tty.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/drivers/char/n_tty.c
===================================================================
--- linux-2.6.orig/drivers/char/n_tty.c 2005-02-16 03:53:53.000000000 +0100
+++ linux-2.6/drivers/char/n_tty.c 2005-02-16 03:56:39.000000000 +0100
@@ -863,7 +863,7 @@ static int n_tty_receive_room(struct tty
* characters will be beeped.
*/
if (tty->icanon && !tty->canon_data)
- return N_TTY_BUF_SIZE;
+ return N_TTY_BUF_SIZE - 1;

if (left > 0)
return left;