Skip to content

Commit

Permalink
commands: don't lock the whole command
Browse files Browse the repository at this point in the history
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 <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Dec 17, 2017
1 parent ce3a1c7 commit 805573c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/lxc/commands.c
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/lxc/commands_utils.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 805573c

Please sign in to comment.