]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxclock: remove pthread_atfork_handlers
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 10 Feb 2018 22:25:18 +0000 (23:25 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sat, 17 Feb 2018 12:46:55 +0000 (13:46 +0100)
They shouldn't be needed anymore.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/attach.c
src/lxc/lxclock.c

index 5028475334f5dc1fd58f1c863602ed75c4847021..cb1d7b97705648ce06ffe6cf5982d8259704db05 100644 (file)
@@ -1189,13 +1189,10 @@ int lxc_attach(const char *name, const char *lxcpath,
                return -1;
        }
 
-       /* Create intermediate subprocess, three reasons:
-        *       1. Runs all pthread_atfork handlers and the child will no
-        *          longer be threaded (we can't properly setns() in a threaded
-        *          process).
-        *       2. We can't setns() in the child itself, since we want to make
+       /* Create intermediate subprocess, two reasons:
+        *       1. We can't setns() in the child itself, since we want to make
         *          sure we are properly attached to the pidns.
-        *       3. Also, the initial thread has to put the attached process
+        *       2. Also, the initial thread has to put the attached process
         *          into the cgroup, which we can only do if we didn't already
         *          setns() (otherwise, user namespaces will hate us).
         */
index ccf9079dad7da72ad1c5e36b13ec711ef38c80f2..600a7402d4de1c8e921ef73d646f6897f16d874f 100644 (file)
@@ -317,23 +317,6 @@ void process_unlock(void)
        unlock_mutex(&thread_mutex);
 }
 
-/* One thread can do fork() while another one is holding a mutex.
- * There is only one thread in child just after the fork(), so no one will ever release that mutex.
- * We setup a "child" fork handler to unlock the mutex just after the fork().
- * For several mutex types, unlocking an unlocked mutex can lead to undefined behavior.
- * One way to deal with it is to setup "prepare" fork handler
- * to lock the mutex before fork() and both "parent" and "child" fork handlers
- * to unlock the mutex.
- * This forbids doing fork() while explicitly holding the lock.
- */
-#ifdef HAVE_PTHREAD_ATFORK
-__attribute__((constructor))
-static void process_lock_setup_atfork(void)
-{
-       pthread_atfork(process_lock, process_unlock, process_unlock);
-}
-#endif
-
 int container_mem_lock(struct lxc_container *c)
 {
        return lxclock(c->privlock, 0);