Unverified Commit b5ea184f by LiFeng Committed by Christian Brauner

Fix comments and add check in lxc_poll.

Add check whether handler->conf->console.path is 'none' Signed-off-by: 's avatarLiFeng <lifeng68@huawei.com>
parent d83e0ffd
...@@ -485,20 +485,25 @@ int lxc_set_state(const char *name, struct lxc_handler *handler, ...@@ -485,20 +485,25 @@ int lxc_set_state(const char *name, struct lxc_handler *handler,
int lxc_poll(const char *name, struct lxc_handler *handler) int lxc_poll(const char *name, struct lxc_handler *handler)
{ {
int ret; int ret;
struct lxc_console *console = &handler->conf->console; bool has_console = true;
struct lxc_epoll_descr descr, descr_console; struct lxc_epoll_descr descr, descr_console;
if (handler->conf->console.path && !strcmp(handler->conf->console.path, "none"))
has_console = false;
ret = lxc_mainloop_open(&descr); ret = lxc_mainloop_open(&descr);
if (ret < 0) { if (ret < 0) {
ERROR("Failed to create mainloop"); ERROR("Failed to create mainloop");
goto out_sigfd; goto out_sigfd;
} }
if (has_console) {
ret = lxc_mainloop_open(&descr_console); ret = lxc_mainloop_open(&descr_console);
if (ret < 0) { if (ret < 0) {
ERROR("Failed to create console mainloop"); ERROR("Failed to create console mainloop");
goto out_mainloop; goto out_mainloop;
} }
}
ret = lxc_mainloop_add_handler(&descr, handler->sigfd, signal_handler, handler); ret = lxc_mainloop_add_handler(&descr, handler->sigfd, signal_handler, handler);
if (ret < 0) { if (ret < 0) {
...@@ -517,6 +522,9 @@ int lxc_poll(const char *name, struct lxc_handler *handler) ...@@ -517,6 +522,9 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
#endif #endif
} }
if (has_console) {
struct lxc_console *console = &handler->conf->console;
ret = lxc_console_mainloop_add(&descr, console); ret = lxc_console_mainloop_add(&descr, console);
if (ret < 0) { if (ret < 0) {
ERROR("Failed to add console handlers to mainloop"); ERROR("Failed to add console handlers to mainloop");
...@@ -528,6 +536,7 @@ int lxc_poll(const char *name, struct lxc_handler *handler) ...@@ -528,6 +536,7 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
ERROR("Failed to add console handlers to console mainloop"); ERROR("Failed to add console handlers to console mainloop");
goto out_mainloop_console; goto out_mainloop_console;
} }
}
ret = lxc_cmd_mainloop_add(name, &descr, handler); ret = lxc_cmd_mainloop_add(name, &descr, handler);
if (ret < 0) { if (ret < 0) {
...@@ -543,11 +552,14 @@ int lxc_poll(const char *name, struct lxc_handler *handler) ...@@ -543,11 +552,14 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
if (ret < 0 || !handler->init_died) if (ret < 0 || !handler->init_died)
goto out_mainloop_console; goto out_mainloop_console;
if (has_console)
ret = lxc_mainloop(&descr_console, 0); ret = lxc_mainloop(&descr_console, 0);
out_mainloop_console: out_mainloop_console:
if (has_console) {
lxc_mainloop_close(&descr_console); lxc_mainloop_close(&descr_console);
TRACE("Closed console mainloop"); TRACE("Closed console mainloop");
}
out_mainloop: out_mainloop:
lxc_mainloop_close(&descr); lxc_mainloop_close(&descr);
......
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