summaryrefslogtreecommitdiff
path: root/debian/patches/libpthread_globsigdisp.patch
blob: 06c3486ccbfac41ea8c83194b32aacf94e030c0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
commit 60d1b9b9198bc8c618596cb0e48687bd41e8adb7
Author: Jeremie Koenig <jk@jk.fr.eu.org>
Date:   Fri Jun 10 05:46:39 2011 +0000

    Mark new threads as global signal receivers
    
    * sysdeps/mach/hurd/pt-sigstate-init.c (__pthread_sigstate_init):
    Call _hurd_sigstate_set_global_rcv for newly created threads.
    * sysdeps/mach/pt-thread-halt.c (__pthread_thread_halt):
    Call _hurd_sigstate_delete on terminated threads.

diff --git a/libpthread/sysdeps/mach/hurd/pt-sigstate-init.c b/libpthread/sysdeps/mach/hurd/pt-sigstate-init.c
index da5a945..f8398f4 100644
--- a/libpthread/sysdeps/mach/hurd/pt-sigstate-init.c
+++ b/libpthread/sysdeps/mach/hurd/pt-sigstate-init.c
@@ -19,6 +19,7 @@
 
 #include <pthread.h>
 #include <hurd/threadvar.h>
+#include <hurd/signal.h>
 
 #include <pt-internal.h>
 
@@ -30,8 +31,21 @@ __pthread_sigstate_init (struct __pthread *thread)
 						thread->stackaddr);
 
   /* The real initialization happens internally in glibc the first
-     time that _hurd_thead_sigstate is called.  */
+     time that _hurd_self_sigstate is called.  */
   *location = 0;
 
+  /* Mark the thread as a global signal receiver so as to conform with
+     the pthread semantics.  However, we must be careful.  The first
+     pthread created is the main thread, during libpthread initialization.
+     We must not mark it, otherwise the sigprocmask call in
+     __pthread_create would try to access _hurd_global_sigstate,
+     which is not initialized yet.  When glibc runs _hurdsig_init later
+     on, the message thread is created, which must not be marked either.  */
+  if (__pthread_num_threads > 2)
+    {
+      struct hurd_sigstate *ss = _hurd_thread_sigstate (thread->kernel_thread);
+      _hurd_sigstate_set_global_rcv (ss);
+    }
+
   return 0;
 }
diff --git a/libpthread/sysdeps/mach/pt-thread-halt.c b/libpthread/sysdeps/mach/pt-thread-halt.c
index a9c3858..808043d 100644
--- a/libpthread/sysdeps/mach/pt-thread-halt.c
+++ b/libpthread/sysdeps/mach/pt-thread-halt.c
@@ -34,6 +34,8 @@ __pthread_thread_halt (struct __pthread *thread)
 {
   if (thread->have_kernel_resources)
     {
+      _hurd_sigstate_delete (thread->kernel_thread);
+
       if (thread == _pthread_self ())
 	{
 	  while (1)