1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

Linux: Use __pthread_attr_setsigmask_internal for timer helper thread

timer_create needs to create threads with all signals blocked,
including SIGTIMER (which happens to equal SIGCANCEL).

Fixes commit b3cae39dcb ("nptl: Start
new threads with all signals blocked [BZ #25098]").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
Florian Weimer
2020-05-19 12:03:44 +02:00
parent ec41af45a6
commit ba9f6ee9bb

View File

@ -136,23 +136,24 @@ __start_helper_thread (void)
(void) pthread_attr_init (&attr); (void) pthread_attr_init (&attr);
(void) pthread_attr_setstacksize (&attr, __pthread_get_minstack (&attr)); (void) pthread_attr_setstacksize (&attr, __pthread_get_minstack (&attr));
/* Block all signals in the helper thread but SIGSETXID. To do this /* Block all signals in the helper thread but SIGSETXID. */
thoroughly we temporarily have to block all signals here. The
helper can lose wakeups if SIGTIMER is not blocked throughout. */
sigset_t ss; sigset_t ss;
__libc_signal_block_app (&ss); __sigfillset (&ss);
__libc_signal_block_sigtimer (NULL); __sigdelset (&ss, SIGSETXID);
int res = __pthread_attr_setsigmask_internal (&attr, &ss);
if (res != 0)
{
pthread_attr_destroy (&attr);
return;
}
/* 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); res = pthread_create (&th, &attr, timer_helper_thread, NULL);
if (res == 0) if (res == 0)
/* 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. */
__libc_signal_restore_set (&ss);
/* No need for the attribute anymore. */ /* No need for the attribute anymore. */
(void) pthread_attr_destroy (&attr); (void) pthread_attr_destroy (&attr);