]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
ttyclient_handler is only cleanup on disconnect
authorMichel Normand <normand@fr.ibm.com>
Wed, 7 Oct 2009 14:06:08 +0000 (16:06 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Wed, 7 Oct 2009 14:06:08 +0000 (16:06 +0200)
this is only a code split to show the real functionality of this
function that is not expecting any received data on the connection

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/start.c

index 8a24c554d31dc11c3d55876d67e997c733d35157..05020e0c88184bd50f195df30ed75b61057c8e4a 100644 (file)
@@ -175,23 +175,35 @@ static int sigchld_handler(int fd, void *data,
        return 1;
 }
 
-static int ttyclient_handler(int fd, void *data,
-                            struct lxc_epoll_descr *descr)
+static void ttyinfo_remove_fd(int fd, struct lxc_tty_info *tty_info)
 {
        int i;
-       struct lxc_tty_info *tty_info = data;
 
        for (i = 0; i < tty_info->nbtty; i++) {
 
                if (tty_info->pty_info[i].busy != fd)
                        continue;
 
-               lxc_mainloop_del_handler(descr, fd);
                tty_info->pty_info[i].busy = 0;
-               close(fd);
        }
 
-       return 0;
+       return;
+}
+
+static void command_fd_cleanup(int fd, struct lxc_tty_info *tty_info,
+                       struct lxc_epoll_descr *descr)
+{
+       ttyinfo_remove_fd(fd, tty_info);
+       lxc_mainloop_del_handler(descr, fd);
+       close(fd);
+}
+
+static int ttyclient_handler(int fd, void *data,
+                            struct lxc_epoll_descr *descr)
+{
+       struct lxc_tty_info *tty_info = data;
+
+       command_fd_cleanup(fd, tty_info, descr);
 }
 
 static int ttyservice_handler(int fd, void *data,