]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
commands: make sure to always close the client fd 3286/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 10 Mar 2020 21:33:00 +0000 (22:33 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 10 Mar 2020 21:44:12 +0000 (22:44 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/commands.c

index cf3b1ed223e7b4cd1a55418713068f98f927a692..247807c868971be1a119bbd166520b69069feaf6 100644 (file)
@@ -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;
 
@@ -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;
                }
 
                /*
@@ -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,