]> git.proxmox.com Git - mirror_lxc.git/commit
make heavier use of process_lock (v2)
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Mon, 16 Sep 2013 23:28:41 +0000 (18:28 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Wed, 18 Sep 2013 18:49:08 +0000 (13:49 -0500)
commit025ed0f3911836b71f498d8368725c77a7e1932a
tree947e6a9a095aa1955376800f1eca94662fce45cc
parentbeb6d93ee2b449ae2ea53125be2f198d15d8f8e8
make heavier use of process_lock (v2)

pthread_mutex_lock() will only return an error if it was set to
PTHREAD_MUTEX_ERRORCHECK and we are recursively calling it (and
would otherwise have deadlocked).  If that's the case then log a
message for future debugging and exit.  Trying to "recover" is
nonsense at that point.

process_lock() was held over too long a time in lxcapi_start()
in the daemonize case.  (note the non-daemonized case still needs a
check to enforce that it must NOT be called while threaded).  Add
process_lock() at least across all open/close/socket() calls.

Anything done after a fork() doesn't need the locks as it is no
longer threaded - so some open/close/dups()s are not locked for
that reason.  However, some common functions are called from both
threaded and non-threaded contexts.  So after doing a fork(), do
a possibly-extraneous process_unlock() to make sure that, if we
were forked while pthread mutex was held, we aren't deadlocked by
nobody.

Tested that lp:~serge-hallyn/+junk/lxc-test still works with this
patch.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Tested-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
25 files changed:
src/lxc/af_unix.c
src/lxc/apparmor.c
src/lxc/attach.c
src/lxc/bdev.c
src/lxc/caps.c
src/lxc/cgroup.c
src/lxc/commands.c
src/lxc/conf.c
src/lxc/console.c
src/lxc/freezer.c
src/lxc/log.c
src/lxc/lxccontainer.c
src/lxc/lxclock.c
src/lxc/lxclock.h
src/lxc/lxcutmp.c
src/lxc/mainloop.c
src/lxc/monitor.c
src/lxc/network.c
src/lxc/nl.c
src/lxc/parse.c
src/lxc/seccomp.c
src/lxc/start.c
src/lxc/state.c
src/lxc/sync.c
src/lxc/utils.c