start: stable-2.1 fixes

- the reboot2() API extension doesn't exist so the command socket fd needs to be closed unconditionally - fix bad cherry-pick that tried to take the lock on the state client list twice Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent df9b5e59
...@@ -365,7 +365,6 @@ static int lxc_serve_state_clients(const char *name, ...@@ -365,7 +365,6 @@ static int lxc_serve_state_clients(const char *name,
handler->state = state; handler->state = state;
TRACE("Set container state to %s", lxc_state2str(state)); TRACE("Set container state to %s", lxc_state2str(state));
process_lock();
if (lxc_list_empty(&handler->state_clients)) { if (lxc_list_empty(&handler->state_clients)) {
TRACE("No state clients registered"); TRACE("No state clients registered");
process_unlock(); process_unlock();
...@@ -763,18 +762,14 @@ void lxc_fini(const char *name, struct lxc_handler *handler) ...@@ -763,18 +762,14 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
*/ */
lxc_monitor_send_state(name, STOPPED, handler->lxcpath); lxc_monitor_send_state(name, STOPPED, handler->lxcpath);
if (handler->conf->reboot == 0) { /* For all new state clients simply close the command socket. This will
/* For all new state clients simply close the command socket. * inform all state clients that the container is STOPPED and also
* This will inform all state clients that the container is * prevents a race between a open()/close() on the command socket
* STOPPED and also prevents a race between a open()/close() on * causing a new process to get ECONNREFUSED because we haven't yet
* the command socket causing a new process to get ECONNREFUSED * closed the command socket.
* because we haven't yet closed the command socket. */
*/ close(handler->conf->maincmd_fd);
close(handler->conf->maincmd_fd); handler->conf->maincmd_fd = -1;
handler->conf->maincmd_fd = -1;
} else {
lxc_set_state(name, handler, STOPPED);
}
if (run_lxc_hooks(name, "post-stop", handler->conf, handler->lxcpath, NULL)) { if (run_lxc_hooks(name, "post-stop", handler->conf, handler->lxcpath, NULL)) {
ERROR("Failed to run lxc.hook.post-stop for container \"%s\".", name); ERROR("Failed to run lxc.hook.post-stop for container \"%s\".", name);
......
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