[patch, libgfortran] PR47694 [4.3/4.4/4.5/4.6 Regression] Fortran read from named pipe fails
Jerry DeLisle
jvdelisle@frontier.com
Sat Feb 19 02:18:00 GMT 2011
Hi folks,
The problem here is that when a read from a named pipe reads more than one line
worth, the formatted IO buffer holds onto the data. When fbuf_read is
subsequently invoked, a sread is dutifully called and it waits for the next read
completion. In the meantime, the next line of data is already in the buffer so
the read waits for another "enter". The reads get out of sync. The problem
does not occur with regular files because there is either always data available
from the file to read or an EOF occurs and in both those cases sread returns.
The patch fixes this by scanning the buffer under certain conditions looking for
an End-of-Line (or EOR). If EOR is found, there is no need to sread again from
the pipe. This patch does add a little overhead from the tight scan loop, but
will save some system calls.
Regression tested on x86-64. I would appreciate others testing please. I do not
know how to create a specific named pipe test in the test suite. See the PR for
the original test.
OK for trunk?
Jerry
2011-02-18 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/47694
* io/fbuf.c (fbuf_read): Scan the buffer for end-of-record and if
found, do not call sread unnecessarily.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr47694.diff
Type: text/x-patch
Size: 927 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20110219/a3aff3eb/attachment.bin>
More information about the Fortran
mailing list