3 Sep 2004 00:25
[Patch] implementation of select for write on pipes
Bob Byrnes <byrnes <at> curl.com>
2004-09-02 22:25:55 GMT
2004-09-02 22:25:55 GMT
The following patch implements select for write on pipes. Currently,
pipes always select writable, which sometimes causes programs like
rsync to hang when the pipe is full. This can be observed directly from
strace output:
http://www.mail-archive.com/rsync <at> lists.samba.org/msg07559.html
We have been using this patch successfully for several months for
automated builds of our Windows products using Cygwin, so it has been
extensively tested. It is the first of several patches that I plan to
contribute, all with the goal of preventing Cygwin hangs, and it does
seem to really improve the behavior of programs like rsync (and sshd)
that use select extensively with pipes.
The existing code uses PeekNamedPipe to implement select for read on
pipes. For the corresponding write test, I used NtQueryInformationFile to
fill in a FILE_PIPE_LOCAL_INFORMATION struct, which contains OutboundQuota
and WriteQuotaAvailable fields that allow us to detect when the pipe is
full. I fixed the signature and return value for NtQueryInformationFile
as well.
Unfortunately, NtQueryInformationFile isn't supported by Win9x, so we
optimistically assume the pipe is always writable on those systems (i.e.,
no change from the status quo).
NtQueryInformationFile also requires FILE_READ_ATTRIBUTES access on the
write side of the pipe, but CreatePipe doesn't set that (at least before
WinXP SP2), so I added a new create_selectable_pipe function to do the
right thing: it uses CreateNamedPipe for the read side, and CreateFile
for the write side (with FILE_READ_ATTRIBUTES). It's important to only
(Continue reading)
Hint: The autoload list is sorted by libraries...
Corinna
RSS Feed