From: Eric Wong <e@80x24.org>
To: cmogstored-public@bogomips.org
Cc: Mykola Golub <trociny@FreeBSD.org>,
Steven Stewart-Gallus <sstewartgallus00@mylangara.bc.ca>
Subject: [PATCH] preserve errno when inside sig handler for self-pipe
Date: Mon, 9 Mar 2015 21:39:49 +0000 [thread overview]
Message-ID: <20150309213949.GA8778@dcvr.yhbt.net> (raw)
We must not clobber errno of the main thread inside signal
handler in case write fails.
This bug only affects systems without epoll_pwait where the
self-pipe is required, so it does not affect modern GNU/Linux
systems; but does affect FreeBSD systems and anybody else
relying on kqueue.
Thanks to Steven Stewart-Gallus for a Ruby bug report which
inspired this fix: https://bugs.ruby-lang.org/issues/10866
Cc: Mykola Golub <trociny@FreeBSD.org>
Cc: Steven Stewart-Gallus <sstewartgallus00@mylangara.bc.ca>
---
Steven: just wanted you to know your original bug report
went a long way :)
selfwake.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/selfwake.c b/selfwake.c
index 1a6908b..06e9d62 100644
--- a/selfwake.c
+++ b/selfwake.c
@@ -42,8 +42,7 @@ void mog_selfwake_wait(struct mog_fd *mfd)
mog_selfwake_drain(mfd);
}
-/* this is async-signal safe (except in the case of bugs) */
-void mog_selfwake_trigger(struct mog_fd *mfd)
+static void selfwake_trigger(struct mog_fd *mfd)
{
ssize_t w;
@@ -64,6 +63,12 @@ retry:
abort();
}
+/* this is async-signal safe (except in the case of our usage bugs) */
+void mog_selfwake_trigger(struct mog_fd *mfd)
+{
+ PRESERVE_ERRNO(selfwake_trigger(mfd));
+}
+
void mog_selfwake_drain(struct mog_fd *mfd)
{
ssize_t r;
--
EW
reply other threads:[~2015-03-09 21:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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://yhbt.net/cmogstored/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150309213949.GA8778@dcvr.yhbt.net \
--to=e@80x24.org \
--cc=cmogstored-public@bogomips.org \
--cc=sstewartgallus00@mylangara.bc.ca \
--cc=trociny@FreeBSD.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.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/cmogstored.git/
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).