From: Christian Brauner Date: Wed, 22 Nov 2017 13:29:32 +0000 (+0100) Subject: commands: don't lock the whole command X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9a8e2b6ef0b6730594e643f8f68b167d094454b5;p=thirdparty%2Flxc.git commands: don't lock the whole command There are multiple reasons why this is not required: - every command is transactional - we only care about the list being modified not the memory allocation and other costly operations Signed-off-by: Christian Brauner --- diff --git a/src/lxc/commands.c b/src/lxc/commands.c index 80ee20240..37db0399f 100644 --- a/src/lxc/commands.c +++ b/src/lxc/commands.c @@ -869,9 +869,7 @@ int lxc_cmd_add_state_client(const char *name, const char *lxcpath, return state; } - process_lock(); ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL); - process_unlock(); if (ret < 0) { ERROR("%s - Failed to execute command", strerror(errno)); return -1; diff --git a/src/lxc/commands_utils.c b/src/lxc/commands_utils.c index 30c224519..e03022f28 100644 --- a/src/lxc/commands_utils.c +++ b/src/lxc/commands_utils.c @@ -33,6 +33,7 @@ #include "commands_utils.h" #include "initutils.h" #include "log.h" +#include "lxclock.h" #include "monitor.h" #include "state.h" #include "utils.h" @@ -209,8 +210,10 @@ int lxc_add_state_client(int state_client_fd, struct lxc_handler *handler, return -ENOMEM; } + process_lock(); lxc_list_add_elem(tmplist, newclient); lxc_list_add_tail(&handler->state_clients, tmplist); + process_unlock(); TRACE("added state client %d to state client list", state_client_fd);