3.3.0: Possible regression in cygwin DLL (Win10); fixed in snapshot

Takashi Yano takashi.yano@nifty.ne.jp
Wed Nov 10 08:30:03 GMT 2021

Hi Corinna,

On Sat, 6 Nov 2021 12:42:46 +0100
Corinna Vinschen wrote:
> On Nov  6 15:10, Takashi Yano wrote:
> > Unfortunately, these solutions do not resolve the issue
> > which is another issue with C# program:
> > https://cygwin.com/pipermail/cygwin/2021-March/247987.html
> > This still needs FILE_SYNCHRONOUS_IO_NONALERT flag.
> If we want to add FILE_SYNCHRONOUS_IO_NONALERT, this would have to be
> solved by running NtReadFile/NtWriteFile synchronously in a thread,
> started on every invocation of raw_read/raw_write.  raw_read/raw_write
> would then call cygwait on the thread object.  To break on signal or
> thread cancallation events, it would have to call CancelSynchronousIo.
> That's certainly doable.

I tried to implement your idea, however, I noticed that
NtQueryObject(ObjectNameInformation) call in
get_query_hdl_per_process() is blocked while reading the
pipe if FIPE_SYNCHRONOUS_IO_NONALERT is set and pipe is
in blocking mode.

So I would like to propose alternative implementation with
FILE_SYNCHRONOUS_IO_NONALERT being set. Please have a look
at attached patch. With this patch, pipe itself in read side
is always set to nonblocking mode and simulate the blocking
behaviour in raw_read(). This can eliminate creating thread
for reading as well as calling CancelSynchronousIo().

Note that setting FILE_SYNCHRONOUS_IO_NONALERT only for read
pipe seems to be enough for C# programs.

What do you think of this implementation?

Takashi Yano <takashi.yano@nifty.ne.jp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pipe20211110.patch
Type: application/octet-stream
Size: 5801 bytes
Desc: not available
URL: <https://cygwin.com/pipermail/cygwin-developers/attachments/20211110/8f3fa40b/attachment.obj>

More information about the Cygwin-developers mailing list