thread safety of fhandler_base_overlapped

Takashi Yano takashi.yano@nifty.ne.jp
Mon Dec 20 23:58:13 GMT 2021


On Mon, 20 Dec 2021 19:02:56 -0400
David McFarland wrote:
> I'm seeing a problem where occasionally write() returns EAGAIN on a
> blocking pipe. I believe this happens when multiple threads are writing
> concurrently to the pipe, and the overlapped structure is modified by
> one thread while another one is between calls to WFMO and
> GetOverlappedResult.
> 
> I found this change:
> 
> =====
> commit 2a4b1de773e6159ea8197b6fc3f7e4845479b476
> Author: Corinna Vinschen <corinna@vinschen.de>
> Date:   Mon Mar 23 21:06:00 2020 +0100
> 
>     Cygwin: serial: use per call OVERLAPPED structs
> 
>     Sharing the OVERLAPPED struct and event object in there between
>     read and select calls in the fhandler might have been a nice
>     optimization way back when, but it is a dangerous, not thread-safe
>     approach.  Fix this by creating per-fhandler, per-call OVERLAPPED
>     structs and event objects on demand.
> 
>     Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
> =====
> 
> which seems to fix a similar problem in fhandler_serial.
> 
> Is is possible that this needs to be done for fhandler_base_overlapped
> as well? I'll try using per-call buffers to see if it fixes my problem.

Pipe code was completely overhauled. Could you please try
the latest developer snapshot?
https://cygwin.com/snapshots/

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>


More information about the Cygwin-developers mailing list