[Patch, libfortran] PR 47694 Reads from named pipe fails

Janne Blomqvist blomqvist.janne@gmail.com
Tue Feb 22 20:22:00 GMT 2011


Hi,

The testcase in PR 47694 shows in issue where gfortran fails to read
from a named pipe. The reason is that libgfortran didn't make sure to
consume all the buffered data before trying to read more. The attached
patch, based on an idea by yours truly and refined by Jerry DeLisle
and me, fixes this by scanning through the buffer one character at a
time; the buffer still ensures that we're doing some amount of
buffering, reducing syscall overhead.

Regtested on x86_64-unknown-linux-gnu, and the pipe testcase in the PR
verified as working properly (AFAICS), Ok for trunk?

TODO: I believe that io/read.c(read_x) should be fixed in the same way
to use fbuf_getc rather than fbuf_read. But lets first see if this
approach works in read_sf and doesn't introduce new regressions..

2011-02-22  Janne Blomqvist  <jb@gcc.gnu.org>
	    Jerry DeLisle    <jvdelisle@gcc.gnu.org>

	PR libfortran/47694
	* io/fbuf.h (fbuf_getptr): New inline function.
	* io/transfer.c (read_sf): Use fbuf_getptr and fbuf_getc to scan
	through the string instead of fbuf_read.



-- 
Janne Blomqvist
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pipe.diff
Type: text/x-patch
Size: 3053 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110222/1ed51739/attachment.bin>


More information about the Gcc-patches mailing list