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;
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) {
close(fd);
}
- handler->conf->maincmd_fd = fd;
return ret;
}
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);
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);
if (conf->reboot) {
INFO("container requested reboot");
conf->reboot = 0;
- if (conf->maincmd_fd)
- close(conf->maincmd_fd);
- conf->maincmd_fd = 0;
goto reboot;
}
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*/
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;
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);
}