This is the mail archive of the
cygwin-developers
mailing list for the Cygwin project.
Re: Rewriting the FIFO code
- From: Ken Brown <kbrown at cornell dot edu>
- To: "cygwin-developers at cygwin dot com" <cygwin-developers at cygwin dot com>
- Date: Fri, 22 Mar 2019 19:27:42 +0000
- Subject: Re: Rewriting the FIFO code
- References: <effca564-9fad-1682-e384-ea4441f85031@cornell.edu> <c95425a2-59f8-f07a-6401-9609be581189@cornell.edu> <a8eee59e-81d1-18f3-d757-6bd70c484881@cornell.edu> <20181226113701.GC4061@calimero.vinschen.de> <17a43c00-ac38-e0d1-6635-d019751fbebe@cornell.edu> <20181226190305.GA3826@calimero.vinschen.de> <b5bd8bff-31a8-b6d0-1e77-62f919eceaea@cornell.edu> <20190123130547.GW2802@calimero.vinschen.de> <a8ad6d45-198e-d1f5-88ee-e9d922ecf699@cornell.edu> <20190228222337.GA20109@calimero.vinschen.de>
On 2/28/2019 5:23 PM, Corinna Vinschen wrote:
> On Feb 28 21:25, Ken Brown wrote:
>> On 1/23/2019 8:05 AM, Corinna Vinschen wrote:
>>> On Jan 22 20:44, Ken Brown wrote:
>>>> On 12/26/2018 2:03 PM, Corinna Vinschen wrote:
>>>>> On Dec 26 14:00, Ken Brown wrote:
>>>>>> Thanks for the encouragement, and Happy Holidays to you too. One question: In
>>>>>> the new AF_UNIX socket code you mostly used NT functions, but the existing FIFO
>>>>>> code uses Win32 functions. Do you prefer NT functions for new code?
>>>>>
>>>>> The NT functions have some advantages over the Win32 functions.
>>>>> For instance, WaitNamedPipe is not interruptible, while
>>>>> NtFsControlFile(FSCTL_PIPE_WAIT) can be called asynchronously
>>>>> and then you can just wait for an event object via cygwait
>>>>> (see fhandler_socket_unix::wait_pipe_thread).
>>>>>
>>>>> So, in theory I'd prefer NT functions, but if you feel uncomfortable
>>>>> and just want to implement away, feel free to go ahead with Win32
>>>>> functions.
>>>>
>>>> I've decided to use Win32 functions for now, not because of discomfort but
>>>> because it allowed me to use more of the existing code. I can always change
>>>> that later.
>>>
>>> Sounds good to me. Just... can we make the fifo pipes PIPE_NOWAIT, by
>>> any chance and make fhandler_fifo a derived class of fhandler_base?
>>
>> I'm working on this now and have two questions.
>>
>> First, if I make fhandler_fifo derived from fhandler_base, don't I
>> have to use NT functions for creating pipes, etc.? (This isn't a
>> problem, but I just want to make sure I understand). For one thing,
>> my understanding is that asynchronous I/O can only be done using
>> overlapped I/O or NT functions. For another thing, fhandler_base uses
>> NT functions for I/O, so I think I have to be consistent with that.
>
> For consistency it would be nice, but no, you don't have to use
> NT function. PIPE_NOWAIT is also available via Win32 API.
I've finally finished a first pass at the FIFO code. I ended up finding it more
convenient to use the NT API and to initially create pipes in blocking mode, so
that I could easily wait for a client to connect. After there's a connection, I
set the pipes non-blocking.
I've tested the code by running Kerrisk's server/client programs cited in
https://cygwin.com/ml/cygwin/2015-03/msg00047.html. I've also run the test case
that I posted in http://www.cygwin.org/ml/cygwin/2015-12/msg00311.html.
There's still a lot more testing that needs to be done, and I haven't thought at
all about the duplexer case yet, but I think I've done enough that a review
would be helpful when you get the time. I'll send the patches to cygwin-patches
shortly.
Once we finish the review/revise cycle, it might make sense to commit the
patches to a topic/fifo branch for further work. I don't think it's ready for
master yet.
Ken