]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(pthread_for_each_thread): New function.
authorUlrich Drepper <drepper@redhat.com>
Thu, 29 Nov 2001 07:45:19 +0000 (07:45 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 29 Nov 2001 07:45:19 +0000 (07:45 +0000)
(__pthread_manager): Handle new REQ_FOR_EACH_THREAD request.

linuxthreads/manager.c

index 97223eab3bd5dfa2a31323b05341c78bc197d715..e0d87896bcb49f63afa936f2546357cbc680eb4d 100644 (file)
@@ -100,6 +100,8 @@ static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode)
      __attribute__ ((noreturn));
 static void pthread_reap_children(void);
 static void pthread_kill_all_threads(int sig, int main_thread_also);
+static void pthread_for_each_thread(void *arg, 
+    void (*fn)(void *, pthread_descr));
 
 /* The server thread managing requests for thread creation and termination */
 
@@ -211,6 +213,11 @@ __pthread_manager(void *arg)
        /* This is just a prod to get the manager to reap some
           threads right away, avoiding a potential delay at shutdown. */
        break;
+      case REQ_FOR_EACH_THREAD:
+       pthread_for_each_thread(request.req_args.for_each.arg,
+                               request.req_args.for_each.fn);
+       restart(request.req_thread);
+       break;
       }
     }
   }
@@ -886,6 +893,20 @@ static void pthread_kill_all_threads(int sig, int main_thread_also)
   }
 }
 
+static void pthread_for_each_thread(void *arg, 
+    void (*fn)(void *, pthread_descr))
+{
+  pthread_descr th;
+
+  for (th = __pthread_main_thread->p_nextlive;
+       th != __pthread_main_thread;
+       th = th->p_nextlive) {
+    fn(arg, th);
+  }
+
+  fn(arg, __pthread_main_thread);
+}
+
 /* Process-wide exit() */
 
 static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode)