diff options
author | Eric Wong <e@80x24.org> | 2015-03-09 21:18:00 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-03-09 21:18:00 +0000 |
commit | d33c7cba557ae40fb55446d841e084a74eacb425 (patch) | |
tree | cc32d54ebe42919c4dcdf52733ff711e1fe99bd6 | |
parent | 58cec82abb8b1e6feea090c72806bd9d8f693a37 (diff) | |
download | cmogstored-d33c7cba557ae40fb55446d841e084a74eacb425.tar.gz |
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>
-rw-r--r-- | selfwake.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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; |