Parcourir la source

Block signals from being handled on worker threads

tags/v1.6.90
Pierre Ossman il y a 8 ans
Parent
révision
a6b00267f2
1 fichiers modifiés avec 12 ajouts et 0 suppressions
  1. 12
    0
      common/os/Thread.cxx

+ 12
- 0
common/os/Thread.cxx Voir le fichier

@@ -20,6 +20,7 @@
#include <windows.h>
#else
#include <pthread.h>
#include <signal.h>
#include <unistd.h>
#endif

@@ -64,8 +65,19 @@ void Thread::start()
throw rdr::SystemException("Failed to create thread", GetLastError());
#else
int ret;
sigset_t all, old;

// Creating threads from libraries is a bit evil, so mitigate the
// issue by at least avoiding signals on these threads
sigfillset(&all);
ret = pthread_sigmask(SIG_SETMASK, &all, &old);
if (ret != 0)
throw rdr::SystemException("Failed to mask signals", ret);

ret = pthread_create((pthread_t*)threadId, NULL, startRoutine, this);

pthread_sigmask(SIG_SETMASK, &old, NULL);

if (ret != 0)
throw rdr::SystemException("Failed to create thread", ret);
#endif

Chargement…
Annuler
Enregistrer