From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: Takashi Yano <takashi.yano@nifty.ne.jp>
Cc: cygwin@cygwin.com
Subject: Re: [ANNOUNCEMENT] TEST: Cygwin 3.1.0-0.1
Date: Thu, 15 Aug 2019 15:09:00 -0000 [thread overview]
Message-ID: <20190815150908.GQ11632@calimero.vinschen.de> (raw)
In-Reply-To: <20190815150436.GP11632@calimero.vinschen.de>
[-- Attachment #1: Type: text/plain, Size: 2910 bytes --]
On Aug 15 17:04, Corinna Vinschen wrote:
> On Aug 15 12:36, Corinna Vinschen wrote:
> > On Aug 15 09:49, Corinna Vinschen wrote:
> > > On Aug 15 04:21, Takashi Yano wrote:
> > > > On Wed, 14 Aug 2019 15:49:00 +0200
> > > > Corinna Vinschen wrote:
> > > > > The only reason I can see is if sigwait_common() returns EINTR because
> > > > > it was interrupted by an unrelated signal. This in turn lets the read()
> > > > > call fail with EINTR and that should be expected by the callers, in
> > > > > theory.
> > > >
> > > > Strangely, this problem also disappears with this patch.
> > > >
> > > > diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
> > > > index 9cf892801..82ac0674f 100644
> > > > --- a/winsup/cygwin/select.cc
> > > > +++ b/winsup/cygwin/select.cc
> > > > @@ -1869,7 +1869,7 @@ thread_signalfd (void *arg)
> > > > switch (WaitForSingleObject (si->evt, INFINITE))
> > > > {
> > > > case WAIT_OBJECT_0:
> > > > - tls->signalfd_select_wait = NULL;
> > > > + //tls->signalfd_select_wait = NULL;
> > > > event = true;
> > > > break;
> > > > default:
> > >
> > > The problem with not setting signalfd_select_wait to NULL here is that
> > > only a subsequent read or sigwaitinfo will do, so there's a time
> > > post-select which will reroute the signal wrongly.
> >
> > Worse, thread_signalfd() closes the handle on exit, so keeping
> > signalfd_select_wait set may result in strange behaviour after select
> > returns.
> >
> > > Any ideas greatly appreciated.
>
> Here's a vague idea:
>
> Right now, signalfd_select_wait is not only used to signal select/poll,
> but also to keep the signal in the queue for the next call to read.
> This read call then calls sigwait_common under the hood.
>
> Afaics, the problem here is that the signal is still in the queue
> even after it has been, basically, assigned to the signalfd. Because
> of that, any subsequent signal dispatch trigger will fire, in the above
> case select's own signal handling.
>
> My (really still vague) idea would be to remove the signalfd_select_wait
> code and call sigwait_common from select instead. If it catched a
> signal, the signal will have been dequeued, as usual. However, the
> select thread function thread_signalfd() would just call sigwait_common,
> too, then create a signalfd_siginfo record which gets assigned to the
> signalfd fhandler. The read function would check if the record is
> valid and return that as first record in the read buffer, and only
> then it would fall back to sigwait_common calls itself.
>
> Does that sound feasible?
Reply to self: Not really because calling sigwait_common from the
thread_signalfd() function will run in the wrong thread with the wrong
tls. Bummer again.
Corinna
--
Corinna Vinschen
Cygwin Maintainer
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-08-15 15:09 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-09 18:55 Corinna Vinschen
2019-08-11 7:28 ` Thorsten Kampe
2019-08-12 13:01 ` Corinna Vinschen
2019-08-12 19:44 ` Takashi Yano
2019-08-13 22:27 ` Thorsten Kampe
2019-08-13 21:45 ` Thorsten Kampe
2019-08-13 21:51 ` Thorsten Kampe
2019-08-14 7:23 ` Takashi Yano
2019-08-12 13:44 ` Takashi Yano
2019-08-12 15:36 ` Corinna Vinschen
2019-08-13 10:48 ` Corinna Vinschen
2019-08-14 11:41 ` Takashi Yano
2019-08-14 11:47 ` Takashi Yano
2019-08-14 13:49 ` Corinna Vinschen
2019-08-14 19:21 ` Takashi Yano
2019-08-15 7:49 ` Corinna Vinschen
2019-08-15 10:36 ` Corinna Vinschen
2019-08-15 15:04 ` Corinna Vinschen
2019-08-15 15:09 ` Corinna Vinschen [this message]
2019-08-16 14:58 ` Corinna Vinschen
2019-08-17 16:59 ` Takashi Yano
2019-08-18 12:07 ` Corinna Vinschen
2019-08-18 12:08 ` Achim Gratz
2019-08-18 14:29 ` Corinna Vinschen
2019-08-18 14:51 ` Achim Gratz
2019-08-19 8:56 ` Corinna Vinschen
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=20190815150908.GQ11632@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin@cygwin.com \
--cc=takashi.yano@nifty.ne.jp \
/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).