Package: glibc / 2.29-3

hurd-i386/tg-setitimer.diff Patch series | download
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
From: Richard Braun <rbraun@sceen.net>
Subject: Fix Hurd implementation of setitimer.
Date:   Wed Dec 26 16:31:14 2012 +0000

    The preemptor sigcode doesn't match since the POSIX sigcode SI_TIMER is
    used when SIGALRM is sent. In addition, The inline version of
    hurd_preempt_signals doesn't update _hurdsig_preempted_set. For these
    reasons, the preemptor would be skipped by post_signal.
    
    * sysdeps/mach/hurd/setitimer.c (setitimer_locked): Fix preemptor setup.

---
 setitimer.c |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

--- a/sysdeps/mach/hurd/setitimer.c
+++ b/sysdeps/mach/hurd/setitimer.c
@@ -128,7 +128,8 @@ timer_thread (void)
 
 /* Forward declaration.  */
 static int setitimer_locked (const struct itimerval *new,
-			     struct itimerval *old, void *crit);
+			     struct itimerval *old, void *crit,
+			     int hurd_siglocked);
 
 static sighandler_t
 restart_itimer (struct hurd_signal_preemptor *preemptor,
@@ -142,7 +143,7 @@ restart_itimer (struct hurd_signal_preem
   /* Either reload or disable the itimer.  */
   __spin_lock (&_hurd_itimer_lock);
   it.it_value = it.it_interval = _hurd_itimerval.it_interval;
-  setitimer_locked (&it, NULL, NULL);
+  setitimer_locked (&it, NULL, NULL, 1);
 
   /* Continue with normal delivery (or hold, etc.) of SIGALRM.  */
   return SIG_ERR;
@@ -154,7 +155,7 @@ restart_itimer (struct hurd_signal_preem
 
 static int
 setitimer_locked (const struct itimerval *new, struct itimerval *old,
-		  void *crit)
+		  void *crit, int hurd_siglocked)
 {
   struct itimerval newval;
   struct timeval now, remaining, elapsed;
@@ -192,16 +193,19 @@ setitimer_locked (const struct itimerval
 	 run `restart_itimer' each time a SIGALRM would arrive.  */
       static struct hurd_signal_preemptor preemptor =
 	{
-	  __sigmask (SIGALRM), 0, 0,
+	  __sigmask (SIGALRM), SI_TIMER, SI_TIMER,
 	  &restart_itimer,
 	};
-      __mutex_lock (&_hurd_siglock);
+      if (!hurd_siglocked)
+	__mutex_lock (&_hurd_siglock);
       if (! preemptor.next && _hurdsig_preemptors != &preemptor)
 	{
 	  preemptor.next = _hurdsig_preemptors;
 	  _hurdsig_preemptors = &preemptor;
+	  _hurdsig_preempted_set |= preemptor.signals;
 	}
-      __mutex_unlock (&_hurd_siglock);
+      if (!hurd_siglocked)
+	__mutex_unlock (&_hurd_siglock);
 
       if (_hurd_itimer_port == MACH_PORT_NULL)
 	{
@@ -349,7 +353,7 @@ __setitimer (enum __itimer_which which,
 
   crit = _hurd_critical_section_lock ();
   __spin_lock (&_hurd_itimer_lock);
-  return setitimer_locked (new, old, crit);
+  return setitimer_locked (new, old, crit, 0);
 }
 
 static void
@@ -364,7 +368,7 @@ fork_itimer (void)
   it = _hurd_itimerval;
   it.it_value = it.it_interval;
 
-  setitimer_locked (&it, NULL, NULL);
+  setitimer_locked (&it, NULL, NULL, 0);
 
   (void) &fork_itimer;		/* Avoid gcc optimizing out the function.  */
 }