public inbox for cygwin-developers@cygwin.com
 help / color / mirror / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: cygwin-developers@cygwin.com
Subject: Re: thread safety of fhandler_base_overlapped
Date: Mon, 20 Dec 2021 18:48:42 -0500	[thread overview]
Message-ID: <a9dc6337-57cc-6eb6-73ef-3460fbaa2a30@cornell.edu> (raw)
In-Reply-To: <vrita6guzxpb.fsf@gmail.com>

On 12/20/2021 6:02 PM, 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.

fhandler_base_overlapped was removed in commit f002d02b17.  Are you looking at 
an old version of the sources?

Ken

  reply	other threads:[~2021-12-20 23:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-20 23:02 David McFarland
2021-12-20 23:48 ` Ken Brown [this message]
2021-12-20 23:58 ` Takashi Yano
2021-12-21  0:03   ` Takashi Yano
2021-12-21  0:59     ` David McFarland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a9dc6337-57cc-6eb6-73ef-3460fbaa2a30@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=cygwin-developers@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).