[PATCH 4/4] Reliably reset signals at server init time

Keith Packard keithp at keithp.com
Mon Jul 9 16:38:15 PDT 2012


Each DDX currently calls OsReleaseSIGIO in case it was suspended when
the server regen started. This causes a BUG to occur if SIGIO was
*not* blocked at that time. Instead of relying on each DDX, make the
OS layer reliably reset all signal state at server init time, ensuring
that signals are suitably unblocked and that the various signal state
counting variables are set back to zero.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 hw/xfree86/common/xf86Init.c |    1 -
 include/os.h                 |    3 +++
 os/osinit.c                  |    1 +
 os/utils.c                   |   13 +++++++++++++
 4 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 9c31d82..0dedd7c 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1012,7 +1012,6 @@ OsVendorInit(void)
     }
 #endif
 #endif
-    OsReleaseSIGIO();
 
     beenHere = TRUE;
 }
diff --git a/include/os.h b/include/os.h
index 34ca1f5..7701c39 100644
--- a/include/os.h
+++ b/include/os.h
@@ -340,6 +340,9 @@ OsBlockSIGIO(void);
 extern _X_EXPORT void
 OsReleaseSIGIO(void);
 
+extern void
+OsResetSignals(void);
+
 extern _X_EXPORT void
 OsAbort(void)
     _X_NORETURN;
diff --git a/os/osinit.c b/os/osinit.c
index 6cc0401..2eb1f7a 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -288,6 +288,7 @@ OsInit(void)
     }
     TimerInit();
     OsVendorInit();
+    OsResetSignals();
     /*
      * No log file by default.  OsVendorInit() should call LogInit() with the
      * log file name if logging to a file is desired.
diff --git a/os/utils.c b/os/utils.c
index 2537934..82192e8 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1243,6 +1243,19 @@ OsReleaseSignals(void)
 #endif
 }
 
+void
+OsResetSignals(void)
+{
+#ifdef SIG_BLOCK
+    while (BlockedSignalCount > 0)
+        OsReleaseSignals();
+#ifdef SIGIO
+    while (sigio_blocked > 0)
+        OsReleaseSIGIO();
+#endif
+#endif
+}
+
 /*
  * Pending signals may interfere with core dumping. Provide a
  * mechanism to block signals when aborting.
-- 
1.7.10.4



More information about the xorg-devel mailing list