]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
htl: fix register-atfork ordering
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 7 Jun 2020 00:57:04 +0000 (02:57 +0200)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 7 Jun 2020 01:00:22 +0000 (03:00 +0200)
* htl/register-atfork.c (__register_atfork): Add new hooks at the end of
the list instead of the beginning.

htl/register-atfork.c

index 256b1148ac7477379ff4065ff70f94e4b5eeafee..4581ac5bbad77326fcf8803b950c06b6a3777877 100644 (file)
@@ -109,15 +109,15 @@ __register_atfork (void (*prepare) (void),
   new->parent = parent;
   new->child = child;
   new->dso_handle = dso_handle;
-  new->prev = NULL;
+  new->next = NULL;
 
   __libc_lock_lock (atfork_lock);
-  new->next = fork_handlers;
-  if (fork_handlers != NULL)
-    fork_handlers->prev = new;
-  fork_handlers = new;
-  if (fork_last_handler == NULL)
-    fork_last_handler = new;
+  new->prev = fork_last_handler;
+  if (fork_last_handler != NULL)
+    fork_last_handler->next = new;
+  if (fork_handlers == NULL)
+    fork_handlers = new;
+  fork_last_handler = new;
   __libc_lock_unlock (atfork_lock);
 
   return 0;