From: Christian Brauner Date: Wed, 22 Nov 2017 13:29:32 +0000 (+0100) Subject: commands: don't lock the whole command X-Git-Tag: lxc-2.0.10~519 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=805573c4c1f1b60cb368d5f0c47b78bbaefc038d;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 ccd99e564..1fbefbf57 100644 --- a/src/lxc/commands.c +++ b/src/lxc/commands.c @@ -868,9 +868,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);