about summary refs log tree commit diff
path: root/nptl/sysdeps/unix/sysv/linux/timer_routines.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-10-28 19:46:50 +0000
committerUlrich Drepper <drepper@redhat.com>2007-10-28 19:46:50 +0000
commitf160a450c930f214f218f0c975abf188d367716f (patch)
tree110fc0d723c02447cc18d452d4886aa88f870efc /nptl/sysdeps/unix/sysv/linux/timer_routines.c
parent22c915ac42b6890383da4b1b0b63f9a15408a01c (diff)
downloadglibc-f160a450c930f214f218f0c975abf188d367716f.tar.gz
glibc-f160a450c930f214f218f0c975abf188d367716f.tar.xz
glibc-f160a450c930f214f218f0c975abf188d367716f.zip
[BZ #5204]
	* crypt/sha256c-test.c: Define TIMEOUT to 6 for ancient hardware.
	* crypt/sha512c-test.c: Likewise.
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux/timer_routines.c')
-rw-r--r--nptl/sysdeps/unix/sysv/linux/timer_routines.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/timer_routines.c b/nptl/sysdeps/unix/sysv/linux/timer_routines.c
index a5eb442251..b159316fb2 100644
--- a/nptl/sysdeps/unix/sysv/linux/timer_routines.c
+++ b/nptl/sysdeps/unix/sysv/linux/timer_routines.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
 
@@ -27,6 +27,12 @@
 #include "kernel-posix-timers.h"
 
 
+/* List of active SIGEV_THREAD timers.  */
+struct timer *__active_timer_sigev_thread;
+/* Lock for the __active_timer_sigev_thread.  */
+pthread_mutex_t __active_timer_sigev_thread_lock = PTHREAD_MUTEX_INITIALIZER;
+
+
 struct thread_start_data
 {
   void (*thrfunc) (sigval_t);
@@ -95,19 +101,36 @@ timer_helper_thread (void *arg)
 	  if (si.si_code == SI_TIMER)
 	    {
 	      struct timer *tk = (struct timer *) si.si_ptr;
-	      struct thread_start_data *td = malloc (sizeof (*td));
 
-	      /* There is not much we can do if the allocation fails.  */
-	      if (td != NULL)
-		{
-		  /* That is the signal we are waiting for.  */
-		  td->thrfunc = tk->thrfunc;
-		  td->sival = tk->sival;
+	      /* Check the timer is still used and will not go away
+		 while we are reading the values here.  */
+	      pthread_mutex_lock (&__active_timer_sigev_thread_lock);
 
-		  pthread_t th;
-		  (void) pthread_create (&th, &tk->attr, timer_sigev_thread,
-					 td);
+	      struct timer *runp = __active_timer_sigev_thread;
+	      while (runp != NULL)
+		if (runp == tk)
+		  break;
+		else
+		  runp = runp->next;
+
+	      if (runp != NULL)
+		{
+		  struct thread_start_data *td = malloc (sizeof (*td));
+
+		  /* There is not much we can do if the allocation fails.  */
+		  if (td != NULL)
+		    {
+		      /* This is the signal we are waiting for.  */
+		      td->thrfunc = tk->thrfunc;
+		      td->sival = tk->sival;
+
+		      pthread_t th;
+		      (void) pthread_create (&th, &tk->attr,
+					     timer_sigev_thread, td);
+		    }
 		}
+
+	      pthread_mutex_unlock (&__active_timer_sigev_thread_lock);
 	    }
 	  else if (si.si_code == SI_TKILL)
 	    /* The thread is canceled.  */