summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-08-03 15:36:34 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-08-07 09:39:56 +1000
commit7f09126e068015db54c56bb982b8f91065375700 (patch)
treec933156e2632b185211e2de5109d92dbcc1b576b /test
parentcb306a8f174bec9ded95191b91797f59250e6808 (diff)
os: don't unconditionally unblock SIGIO in OsReleaseSignals()
Calling OsReleaseSignal() inside the signal handler releases SIGIO, causing the signal handler to be called again from within the handler. Practical use-case: when synaptics calls TimerSet in the signal handler, this causes the signals to be released, eventually hanging the server. Regression introduced in 08962951de. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Diffstat (limited to 'test')
-rw-r--r--test/os.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/os.c b/test/os.c
index 1460a34d6..8f1107ded 100644
--- a/test/os.c
+++ b/test/os.c
@@ -28,6 +28,21 @@
#include <signal.h>
#include "os.h"
+static int last_signal = 0;
+static int expect_signal = 0;
+
+static void sighandler(int signal)
+{
+ assert(expect_signal);
+ expect_signal = 0;
+ if (!last_signal)
+ raise(signal);
+ OsBlockSignals();
+ OsReleaseSignals();
+ last_signal = 1;
+ expect_signal = 1;
+}
+
static int
sig_is_blocked(int sig)
{
@@ -118,7 +133,27 @@ static void block_sigio_test(void)
assert(sig_is_blocked(SIGIO));
OsReleaseSignals();
assert(!sig_is_blocked(SIGIO));
+#endif
+}
+static void block_sigio_test_nested(void)
+{
+#ifdef SIG_BLOCK
+ /* Check for bug releasing SIGIO during SIGIO signal handling.
+ test case:
+ raise signal
+ → in signal handler:
+ raise signal
+ OsBlockSignals()
+ OsReleaseSignals()
+ tail guard
+ tail guard must be hit.
+ */
+ sighandler_t old_handler;
+ old_handler = signal(SIGIO, sighandler);
+ expect_signal = 1;
+ assert(raise(SIGIO) == 0);
+ assert(signal(SIGIO, old_handler) == sighandler);
#endif
}
@@ -126,5 +161,6 @@ int
main(int argc, char **argv)
{
block_sigio_test();
+ block_sigio_test_nested();
return 0;
}