Skip to content

Commit

Permalink
Merge pull request #3286 from brauner/2020-03-10/fixes
Browse files Browse the repository at this point in the history
commands: make sure to always close the client fd
  • Loading branch information
stgraber committed Mar 10, 2020
2 parents c2250e7 + cd5369b commit 85e9c76
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lxc/commands.c
Expand Up @@ -1327,8 +1327,7 @@ static void lxc_cmd_fd_cleanup(int fd, struct lxc_handler *handler,
lxc_terminal_free(handler->conf, fd);
lxc_mainloop_del_handler(descr, fd);

switch (cmd) {
case LXC_CMD_ADD_STATE_CLIENT:
if (cmd == LXC_CMD_ADD_STATE_CLIENT) {
lxc_list_for_each_safe(cur, &handler->conf->state_clients, next) {
struct lxc_state_client *client = cur->elem;

Expand All @@ -1344,7 +1343,8 @@ static void lxc_cmd_fd_cleanup(int fd, struct lxc_handler *handler,
* No need to walk the whole list. If we found the state
* client fd there can't be a second one.
*/
break;
TRACE("Closed state client fd %d\n", fd);
return;
}

/*
Expand All @@ -1353,10 +1353,10 @@ static void lxc_cmd_fd_cleanup(int fd, struct lxc_handler *handler,
* was already reached by the time we were ready to add it. So
* fallthrough and clean it up.
*/
__fallthrough;
default:
close(fd);
TRACE("Closing state client fd %d not present in state client list\n", fd);
}

close(fd);
}

static int lxc_cmd_handler(int fd, uint32_t events, void *data,
Expand Down

0 comments on commit 85e9c76

Please sign in to comment.