mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-01 10:06:57 +03:00
Make sure helper thread has all signals blocked.
This commit is contained in:
@ -32,6 +32,14 @@
|
|||||||
static void *
|
static void *
|
||||||
timer_sigev_thread (void *arg)
|
timer_sigev_thread (void *arg)
|
||||||
{
|
{
|
||||||
|
/* The parent thread has all signals blocked. This is a bit
|
||||||
|
surprising for user code, although valid. We unblock all
|
||||||
|
signals. */
|
||||||
|
sigset_t ss;
|
||||||
|
sigemptyset (&ss);
|
||||||
|
INTERNAL_SYSCALL_DECL (err);
|
||||||
|
INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, NULL, _NSIG / 8);
|
||||||
|
|
||||||
struct timer *tk = (struct timer *) arg;
|
struct timer *tk = (struct timer *) arg;
|
||||||
|
|
||||||
/* Call the user-provided function. */
|
/* Call the user-provided function. */
|
||||||
@ -45,16 +53,10 @@ timer_sigev_thread (void *arg)
|
|||||||
static void *
|
static void *
|
||||||
timer_helper_thread (void *arg)
|
timer_helper_thread (void *arg)
|
||||||
{
|
{
|
||||||
/* Block all signals. We will only wait for the signal the kernel
|
/* Wait for the SIGTIMER signal and none else. */
|
||||||
will send. */
|
|
||||||
sigset_t ss;
|
sigset_t ss;
|
||||||
sigemptyset (&ss);
|
sigemptyset (&ss);
|
||||||
sigaddset (&ss, SIGTIMER);
|
sigaddset (&ss, SIGTIMER);
|
||||||
/* SIGTIMER is the same signal as SIGCANCEL and it is therefore
|
|
||||||
unblocked so far. Block it for this thread, we handle
|
|
||||||
cancellation explicitly. */
|
|
||||||
INTERNAL_SYSCALL_DECL (err);
|
|
||||||
INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_BLOCK, &ss, NULL, _NSIG / 8);
|
|
||||||
|
|
||||||
/* Endless loop of waiting for signals. The loop is only ended when
|
/* Endless loop of waiting for signals. The loop is only ended when
|
||||||
the thread is canceled. */
|
the thread is canceled. */
|
||||||
@ -119,6 +121,14 @@ __start_helper_thread (void)
|
|||||||
(void) pthread_attr_init (&attr);
|
(void) pthread_attr_init (&attr);
|
||||||
(void) pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
|
(void) pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
|
||||||
|
|
||||||
|
/* Block all signals in the helper thread. To do this thoroughly we
|
||||||
|
temporarily have to block all signals here. */
|
||||||
|
sigset_t ss;
|
||||||
|
sigset_t oss;
|
||||||
|
sigfillset (&ss);
|
||||||
|
INTERNAL_SYSCALL_DECL (err);
|
||||||
|
INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, &oss, _NSIG / 8);
|
||||||
|
|
||||||
/* Create the helper thread for this timer. */
|
/* Create the helper thread for this timer. */
|
||||||
pthread_t th;
|
pthread_t th;
|
||||||
int res = pthread_create (&th, &attr, timer_helper_thread, NULL);
|
int res = pthread_create (&th, &attr, timer_helper_thread, NULL);
|
||||||
@ -126,6 +136,10 @@ __start_helper_thread (void)
|
|||||||
/* We managed to start the helper thread. */
|
/* We managed to start the helper thread. */
|
||||||
__helper_tid = ((struct pthread *) th)->tid;
|
__helper_tid = ((struct pthread *) th)->tid;
|
||||||
|
|
||||||
|
/* Restore the signal mask. */
|
||||||
|
INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &oss, NULL,
|
||||||
|
_NSIG / 8);
|
||||||
|
|
||||||
/* No need for the attribute anymore. */
|
/* No need for the attribute anymore. */
|
||||||
(void) pthread_attr_destroy (&attr);
|
(void) pthread_attr_destroy (&attr);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user