Commit 2a061f55 by Daniel Lezcano
parents d984bb4e d2e30e99
......@@ -287,11 +287,9 @@ out_close:
goto out;
}
extern int lxc_command_mainloop_add(const char *name,
struct lxc_epoll_descr *descr,
struct lxc_handler *handler)
extern int lxc_command_init(const char *name, struct lxc_handler *handler)
{
int ret, fd;
int fd;
char path[sizeof(((struct sockaddr_un *)0)->sun_path)] = { 0 };
char *offset = &path[1];
int rc, len;
......@@ -320,6 +318,16 @@ extern int lxc_command_mainloop_add(const char *name,
return -1;
}
handler->conf->maincmd_fd = fd;
return 0;
}
extern int lxc_command_mainloop_add(const char *name,
struct lxc_epoll_descr *descr,
struct lxc_handler *handler)
{
int ret, fd = handler->conf->maincmd_fd;
ret = lxc_mainloop_add_handler(descr, fd, incoming_command_handler,
handler);
if (ret) {
......@@ -327,6 +335,5 @@ extern int lxc_command_mainloop_add(const char *name,
close(fd);
}
handler->conf->maincmd_fd = fd;
return ret;
}
......@@ -60,6 +60,7 @@ extern int lxc_command_connected(const char *name, struct lxc_command *command,
struct lxc_epoll_descr;
struct lxc_handler;
extern int lxc_command_init(const char *name, struct lxc_handler *handler);
extern int lxc_command_mainloop_add(const char *name, struct lxc_epoll_descr *descr,
struct lxc_handler *handler);
......
......@@ -1895,6 +1895,7 @@ struct lxc_conf *lxc_conf_init(void)
new->console.master = -1;
new->console.slave = -1;
new->console.name[0] = '\0';
new->maincmd_fd = -1;
new->rootfs.mount = default_rootfs_mount;
new->loglevel = LXC_LOG_PRIORITY_NOTSET;
lxc_list_init(&new->cgroup);
......
......@@ -381,9 +381,6 @@ reboot:
if (conf->reboot) {
INFO("container requested reboot");
conf->reboot = 0;
if (conf->maincmd_fd)
close(conf->maincmd_fd);
conf->maincmd_fd = 0;
goto reboot;
}
......
......@@ -377,9 +377,12 @@ struct lxc_handler *lxc_init(const char *name, struct lxc_conf *conf)
goto out_free;
}
if (lxc_command_init(name, handler))
goto out_free_name;
if (lxc_read_seccomp_config(conf) != 0) {
ERROR("failed loading seccomp policy");
goto out_free_name;
goto out_close_maincmd_fd;
}
/* Begin the set the state to STARTING*/
......@@ -421,6 +424,9 @@ out_delete_tty:
lxc_delete_tty(&conf->tty_info);
out_aborting:
lxc_set_state(name, handler, ABORTING);
out_close_maincmd_fd:
close(conf->maincmd_fd);
conf->maincmd_fd = -1;
out_free_name:
free(handler->name);
handler->name = NULL;
......@@ -446,6 +452,8 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
lxc_delete_console(&handler->conf->console);
lxc_delete_tty(&handler->conf->tty_info);
close(handler->conf->maincmd_fd);
handler->conf->maincmd_fd = -1;
free(handler->name);
free(handler);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment