unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: guile-devel <guile-devel@gnu.org>
Subject: Re: a little puzzle
Date: Sun, 10 Oct 2010 16:58:04 +0200	[thread overview]
Message-ID: <m3k4lqf62r.fsf@unquote.localdomain> (raw)
In-Reply-To: <m3ocb4fv4m.fsf@unquote.localdomain> (Andy Wingo's message of "Fri, 08 Oct 2010 19:32:25 +0200")

On Fri 08 Oct 2010 19:32, Andy Wingo <wingo@pobox.com> writes:

> On Fri 08 Oct 2010 19:14, Andy Wingo <wingo@pobox.com> writes:
>
>> That's right: two throws for the price of one! The interrupted syscall,
>> and then the asynchronous signal. Fun...
>
> I propose to fix it with a patch like this:
>
> --- a/libguile/error.c
> +++ b/libguile/error.c
> @@ -147,6 +147,7 @@ void
>  scm_syserror (const char *subr)
>  {
>    SCM err = scm_from_int (SCM_I_ERRNO ());
> +  SCM_ASYNC_TICK;
>    scm_error (scm_system_error_key,
>  	     subr,
>  	     "~A",

I did so, wrapping in #ifdef EINTR, and with the additional comment:

  /* It could be that we're getting here because the syscall was
     interrupted by a signal.  In that case a signal handler might have
     been queued to run.  The signal handler probably throws an
     exception.

     If we don't try to run the signal handler now, it will run later,
     which would result in two exceptions being thrown: this syserror,
     and then at some later time the exception thrown by the async
     signal handler.

     The problem is that we don't know if handling the signal caused an
     async to be queued.  By this time scmsigs.c:take_signal will have
     written a byte on the fd, but we don't know if the signal-handling
     thread has read it off and queued an async.

     Ideally we need some API like scm_i_ensure_signals_delivered() to
     catch up signal delivery.  Barring that, we just cross our digits
     and pray; it could be that we handle the signal in time, and just
     throw once, or it could be that we miss the deadline and throw
     twice.
  */
#ifdef EINTR
  if (scm_to_int (err) == EINTR)
    SCM_ASYNC_TICK;
#endif

-- 
http://wingolog.org/



      reply	other threads:[~2010-10-10 14:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-08 17:14 a little puzzle Andy Wingo
2010-10-08 17:32 ` Andy Wingo
2010-10-10 14:58   ` Andy Wingo [this message]

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

  List information: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=m3k4lqf62r.fsf@unquote.localdomain \
    --to=wingo@pobox.com \
    --cc=guile-devel@gnu.org \
    /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).