Mesa (master): gallium: block signals for new thread when spawning threads

Dave Airlie airlied at kemper.freedesktop.org
Sun May 15 20:49:14 UTC 2011


Module: Mesa
Branch: master
Commit: bc16c73407d11bb6702cf7de9925bfaeb80a5272
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bc16c73407d11bb6702cf7de9925bfaeb80a5272

Author: Dave Airlie <airlied at redhat.com>
Date:   Sun May 15 16:41:54 2011 +1000

gallium: block signals for new thread when spawning threads

I'm hard pressed to think of any reason a gallium thread would want to
receive a signal, especially considering its probably loaded as a library
and you don't want the threads interfering with the main threads signal
handling.

This solves a problem loading llvmpipe into the X server for AIGLX,
where the X server relies on the SIGIO signal going to the main thread,
but once llvmpipe loads the SIGIO can end up in any of its threads.

Signed-off-by: Dave Airlie <airlied at redhat.com>

---

 src/gallium/auxiliary/os/os_thread.h |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h
index 8173d4c..6b4281a 100644
--- a/src/gallium/auxiliary/os/os_thread.h
+++ b/src/gallium/auxiliary/os/os_thread.h
@@ -56,7 +56,14 @@ typedef pthread_t pipe_thread;
 static INLINE pipe_thread pipe_thread_create( void *(* routine)( void *), void *param )
 {
    pipe_thread thread;
-   if (pthread_create( &thread, NULL, routine, param ))
+   sigset_t saved_set, new_set;
+   int ret;
+
+   sigfillset(&new_set);
+   pthread_sigmask(SIG_SETMASK, &new_set, &saved_set);
+   ret = pthread_create( &thread, NULL, routine, param );
+   pthread_sigmask(SIG_SETMASK, &saved_set, NULL);
+   if (ret)
       return 0;
    return thread;
 }




More information about the mesa-commit mailing list