aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os/utils.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-07-06 09:31:01 +0200
committermarha <marha@users.sourceforge.net>2012-07-06 09:31:01 +0200
commit405ae9defaaa03d4d305b6264a744107c3dd460d (patch)
treee119a54d876fa737d859718afbde7ef507702631 /xorg-server/os/utils.c
parent3a5976985ab1ca641b095a72730f1f3d3bd5f9bc (diff)
parent336bad93d146931c160d8517edfdf0bee49ad9f7 (diff)
downloadvcxsrv-405ae9defaaa03d4d305b6264a744107c3dd460d.tar.gz
vcxsrv-405ae9defaaa03d4d305b6264a744107c3dd460d.tar.bz2
vcxsrv-405ae9defaaa03d4d305b6264a744107c3dd460d.zip
Merge remote-tracking branch 'origin/released'
Conflicts: xorg-server/dix/dispatch.c xorg-server/dix/privates.c xorg-server/hw/kdrive/ephyr/ephyr.c xorg-server/hw/kdrive/src/kinput.c
Diffstat (limited to 'xorg-server/os/utils.c')
-rw-r--r--xorg-server/os/utils.c54
1 files changed, 51 insertions, 3 deletions
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c
index e94179518..d61a9d67d 100644
--- a/xorg-server/os/utils.c
+++ b/xorg-server/os/utils.c
@@ -1226,15 +1226,15 @@ OsBlockSignals(void)
if (BlockedSignalCount++ == 0) {
sigset_t set;
+#ifdef SIGIO
+ OsBlockSIGIO();
+#endif
sigemptyset(&set);
sigaddset(&set, SIGALRM);
sigaddset(&set, SIGVTALRM);
#ifdef SIGWINCH
sigaddset(&set, SIGWINCH);
#endif
-#ifdef SIGIO
- sigaddset(&set, SIGIO);
-#endif
sigaddset(&set, SIGTSTP);
sigaddset(&set, SIGTTIN);
sigaddset(&set, SIGTTOU);
@@ -1244,12 +1244,60 @@ OsBlockSignals(void)
#endif
}
+#ifdef SIG_BLOCK
+static sig_atomic_t sigio_blocked;
+#endif
+
+/**
+ * returns zero if this call caused SIGIO to be blocked now, non-zero if it
+ * was already blocked by a previous call to this function.
+ */
+int
+OsBlockSIGIO(void)
+{
+#ifdef SIGIO
+#ifdef SIG_BLOCK
+ if (sigio_blocked++ == 0) {
+ sigset_t set, old;
+ int ret;
+
+ sigemptyset(&set);
+ sigaddset(&set, SIGIO);
+ sigprocmask(SIG_BLOCK, &set, &old);
+ ret = sigismember(&old, SIGIO);
+ return ret;
+ } else
+ return 1;
+#endif
+#endif
+}
+
+void
+OsReleaseSIGIO(void)
+{
+#ifdef SIGIO
+#ifdef SIG_BLOCK
+ if (--sigio_blocked == 0) {
+ sigset_t set;
+
+ sigemptyset(&set);
+ sigaddset(&set, SIGIO);
+ sigprocmask(SIG_UNBLOCK, &set, NULL);
+ } else if (sigio_blocked < 0) {
+ BUG_WARN(sigio_blocked < 0);
+ sigio_blocked = 0;
+ }
+#endif
+#endif
+}
+
void
OsReleaseSignals(void)
{
#ifdef SIG_BLOCK
if (--BlockedSignalCount == 0) {
sigprocmask(SIG_SETMASK, &PreviousSignalMask, 0);
+ OsReleaseSIGIO();
}
#endif
}