Enable global signal distribution in htl
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 29 Jun 2024 10:27:34 +0000 (13:27 +0300)
committerAdrian Bunk <bunk@debian.org>
Sat, 29 Jun 2024 10:27:34 +0000 (13:27 +0300)
* sysdeps/mach/hurd/htl/pt-sigstate-init.c (__pthread_sigstate_init):
Call _hurd_sigstate_set_global_rcv().
* sysdeps/mach/hurd/htl/pt-sigstate-destroy.c
(__pthread_sigstate_destroy): Call _hurd_sigstate_delete().
* sysdeps/mach/hurd/htl/pt-sigstate.c: Include <hurd/msg.h>
(__pthread_sigstate): Use _hurd_sigstate_lock()/_hurd_sigstate_unlock()
and _hurd_sigstate_pending(). Call __msg_sig_post() to wake up thread
with pending signals.
* sysdeps/mach/hurd/Makefile (LDLIBS-pthread.so): Add
$(objdir)/hurd/libhurduser.so.

Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name libpthread_sigs.diff

sysdeps/mach/hurd/Makefile
sysdeps/mach/hurd/htl/pt-sigstate-destroy.c
sysdeps/mach/hurd/htl/pt-sigstate-init.c
sysdeps/mach/hurd/htl/pt-sigstate.c

index 3a853a6cd9e99e508968e14c284e10521ba89130..8a865a0e1f40471c5ef8783d032f058c0a357d5b 100644 (file)
@@ -206,4 +206,6 @@ ifeq ($(subdir),nis)
 CFLAGS-ypclnt.c += -DUSE_BINDINGDIR=1
 endif
 
+LDLIBS-pthread.so += $(objdir)/hurd/libhurduser.so
+
 endif  # in-Makerules
index e7154a371d9eae4a0311988a969ae317aedea1c5..229a415487c94c52a7ce40e4708bb995b69bdd8f 100644 (file)
@@ -23,4 +23,5 @@
 void
 __pthread_sigstate_destroy (struct __pthread *thread)
 {
+  _hurd_sigstate_delete (thread->kernel_thread);
 }
index 70832f957677bf3c531049baef17ef70700b0739..507fb8ade218181e9c0d525661ebc2324800254f 100644 (file)
@@ -35,7 +35,7 @@ __pthread_sigstate_init (struct __pthread *thread)
   if (do_init_global)
     {
       struct hurd_sigstate *ss = _hurd_thread_sigstate (thread->kernel_thread);
-      (void) ss;
+      _hurd_sigstate_set_global_rcv (ss);
     }
   else if (__pthread_num_threads >= 2)
     do_init_global = 1;
index f7050ec0df3e05853cea66ab82fd2bc872a79989..2ddceb229e1f488d4c0a6aa06984050ee9fac48f 100644 (file)
@@ -20,6 +20,7 @@
 #include <assert.h>
 #include <signal.h>
 #include <hurd/signal.h>
+#include <hurd/msg.h>
 
 #include <pt-internal.h>
 
@@ -29,11 +30,12 @@ __pthread_sigstate (struct __pthread *thread, int how,
 {
   error_t err = 0;
   struct hurd_sigstate *ss;
+  sigset_t pending;
 
   ss = _hurd_thread_sigstate (thread->kernel_thread);
   assert (ss);
 
-  __spin_lock (&ss->lock);
+  _hurd_sigstate_lock (ss);
 
   if (oset != NULL)
     *oset = ss->blocked;
@@ -64,7 +66,13 @@ __pthread_sigstate (struct __pthread *thread, int how,
   if (!err && clear_pending)
     __sigemptyset (&ss->pending);
 
-  __spin_unlock (&ss->lock);
+  pending = _hurd_sigstate_pending (ss) & ~ss->blocked;
+  _hurd_sigstate_unlock (ss);
+
+  if (!err && pending)
+    /* Send a message to the signal thread so it
+       will wake up and check for pending signals.  */
+    __msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ());
 
   return err;
 }