[PATCH 3/4] server: Don't block when writing to named pipes in PIPE_NOWAIT mode.

Jacek Caban jacek at codeweavers.com
Fri Oct 4 11:14:00 CDT 2019


On 10/3/19 8:11 PM, Brendan Shanks wrote:
>> On Oct 3, 2019, at 5:01 AM, Jacek Caban <jacek at codeweavers.com> wrote:
>>
>> Hi Brendan,
>>
>> On 10/3/19 12:45 AM, Brendan Shanks wrote:
>>> Hi Jacek,
>>> In v2 of the patch I added a test for this (an overlapped read followed by a nonblocking write larger than the pipe buffer), on Wine the write was returning with 0 bytes written. My fix was to only do the wake/free from reselect_write_queue() if there’s no asyncs waiting in the reader read_q, not sure if this is correct or I’m overlooking something though.
>>
>> Tests looks much better now, thanks. Implementation seems questionable because non-blocking write may block now. For an example do a pending read with size 1 followed by write of size 514. I'd expect write to fail and read to not be satisfied on Windows. I think that with your implementation, read will be satisfied and write will block.
> I tried this out, on Windows the write succeeds but only writes 1 byte, and the read completes with 1 byte as well. On Wine this almost works right, but WriteFile returns 0 for the bytes written even though the read completes with 1 byte. I’ll fix this and add these tests for v3.


Okay, so Windows does partial writes after all. I will comment on the 
new patch separately, but it looks almost good now.


> I also tried a pending read of 1 byte and write 513 bytes, in that case the read and write both complete fully and the 512 bytes stays in the pipe for the next read call.


FWIW, it's not really needed in this series, but another interesting 
corner case would be a pending 0-size read in message mode and write of 
513 bytes. I don't expect surprises through.


Thanks,

Jacek




More information about the wine-devel mailing list