Re: [PATCH] tty: Fix pty master read() after slave closes

Mikael Pettersson
2013-09-28T17:37:24Z

Peter Hurley writes:
> On 09/27/2013 01:27 PM, Peter Hurley wrote:
> > Commit f95499c3030fe1bfad57745f2db1959c5b43dca8,
> > n_tty: Don't wait for buffer work in read() loop
> > creates a race window which can cause a pty master read()
> > to miss the last pty slave write(s) and return -EIO instead,
> > thus signalling the pty slave is closed. This can happen when
> > the pty slave is written and immediately closed but before the
> > tty buffer i/o loop receives the new input; the pty master
> > read() is scheduled, sees its read buffer is empty and the
> > pty slave has been closed, and exits.
> >
> > Because tty_flush_to_ldisc() has significant performance impact
> > for parallel i/o, rather than revert the commit, special case this
> > condition (ie., when the read buffer is empty and the 'other' pty
> > has been closed) and, only then, wait for buffer work to complete
> > before re-testing if the read buffer is still empty.
> >
> > As before, subsequent pty master reads return any available data
> > until no more data is available, and then returns -EIO to
> > indicate the pty slave has closed.
> >
> > Reported-by: Mikael Pettersson <mikpelinux@gmail.com>
> > Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>
> I tested this patch with the gcc ada ACATS testsuite and got this
> summary so all seems ok with this patch.
>
> === acats Summary ===
> # of expected passes 805
> # of unexpected failures 0
>
> ...
>
> === acats Summary ===
> # of expected passes 772
> # of unexpected failures 0
>
> ...
>
> === acats Summary ===
> # of expected passes 743
> # of unexpected failures 0
>
> Mikael,
>
> I'd appreciate if you could re-test with this patch and
> confirm the issue is fixed.

I did a big pile of gcc bootstrap + regression test runs today with
this patch, and everything looks good. Thus:

Tested-by: Mikael Pettersson <mikpelinux@gmail.com>

Thanks,

/Mikael