Patchwork [RFC,1/2] Signals: fix race condition with aio-compat

login
register
mail settings
Submitter Alexandre Raymond
Date July 20, 2011, 5:01 a.m.
Message ID <1311138090-2909-2-git-send-email-cerbere@gmail.com>
Download mbox | patch
Permalink /patch/105581/
State New
Headers show

Comments

Alexandre Raymond - July 20, 2011, 5:01 a.m.
There appears to be a race condition when SIGUSR2 is not handled synchronously
by the signalfd thread. This caused random freezes/segfaults under OS X.

This fix also appears to fix most of the I/O errors that occur when the io-thread
is enabled on OS X.

Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
---
 cpus.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

Patch

diff --git a/cpus.c b/cpus.c
index 3035314..f466d95 100644
--- a/cpus.c
+++ b/cpus.c
@@ -391,10 +391,6 @@  static int qemu_signal_init(void)
     sigset_t set;
 
 #ifdef CONFIG_IOTHREAD
-    /* SIGUSR2 used by posix-aio-compat.c */
-    sigemptyset(&set);
-    sigaddset(&set, SIGUSR2);
-    pthread_sigmask(SIG_UNBLOCK, &set, NULL);
 
     /*
      * SIG_IPI must be blocked in the main thread and must not be caught
@@ -406,11 +402,13 @@  static int qemu_signal_init(void)
     pthread_sigmask(SIG_BLOCK, &set, NULL);
 
     sigemptyset(&set);
+    sigaddset(&set, SIGUSR2);
     sigaddset(&set, SIGIO);
     sigaddset(&set, SIGALRM);
     sigaddset(&set, SIGBUS);
 #else
     sigemptyset(&set);
+    sigaddset(&set, SIGUSR2);
     sigaddset(&set, SIGBUS);
     if (kvm_enabled()) {
         /*