This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: Getting the pipe guard
- From: Christopher Faylor <cgf-no-personal-reply-please at cygwin dot com>
- To: cygwin-patches at cygwin dot com
- Date: Sun, 21 May 2006 01:26:41 -0400
- Subject: Re: Getting the pipe guard
- References: <ba40711f0605201843g3ed55755ue3140fd2b1b66acb@mail.gmail.com>
- Reply-to: cygwin-patches at cygwin dot com
On Sat, May 20, 2006 at 09:43:16PM -0400, Lev Bishop wrote:
>Index: select.cc
>===================================================================
>RCS file: /cvs/src/src/winsup/cygwin/select.cc,v
>retrieving revision 1.123
>diff -u -p -d -r1.123 select.cc
>--- select.cc 24 Apr 2006 15:16:45 -0000 1.123
>+++ select.cc 21 May 2006 00:56:04 -0000
>@@ -689,14 +689,18 @@ pipe_cleanup (select_record *, select_st
> int
> fhandler_pipe::ready_for_read (int fd, DWORD howlong)
> {
>- int res;
>+ int res = true;
>+ const HANDLE w4[2] = {signal_arrived, get_guard ()};
> if (howlong)
>- res = true;
>+ {
>+ if (w4[2] && WAIT_OBJECT_0 == WaitForMultipleObjects (2, w4, 0, INFINITE))
>+ {
>+ set_sig_errno (EINTR);
>+ return 0;
>+ }
>+ }
> else
> res = fhandler_base::ready_for_read (fd, howlong);
>-
>- if (res)
>- get_guard ();
> return res;
> }
The above code seems to be needed but I can't see how it could affect the
non-blocking case since "howlong" is only set in the blocking case.
I've checked in a variation of the above plus some modifications to
pipe.cc which prevent some handle stomping and may make things work
better.
Thanks for the patch.
cgf