[lxc-devel] [lxc/master] start: send state to legacy lxc-monitord state server even if no state clients registered

0x0916 on Github lxc-bot at linuxcontainers.org
Sat Jul 1 05:58:49 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 698 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170701/13918dfa/attachment.bin>
-------------- next part --------------
From 8269ef6e975069504f86b10729b467d767576a1b Mon Sep 17 00:00:00 2001
From: 0x0916 <w at laoqinren.net>
Date: Sat, 1 Jul 2017 13:44:41 +0800
Subject: [PATCH] start: send state to legacy lxc-monitord state server even if
 no state clients registered

This pr https://github.com/lxc/lxc/pull/1618 kill lxc-monitord, for backwards compatibility,
we also send state to legacy lxc-monitord state server in function `lxc_set_state`.

we should send state at the beginning of the function, otherwise `lxc-monitor` client will
not get state change event if container changed state to `STARTING` or `RUNNING`.

Signed-off-by: 0x0916 <w at laoqinren.net>
---
 src/lxc/start.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/lxc/start.c b/src/lxc/start.c
index b7afc7bab..24d11536a 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -349,6 +349,11 @@ int lxc_set_state(const char *name, struct lxc_handler *handler,
 	struct state_client *client;
 	struct lxc_msg msg = {.type = lxc_msg_state, .value = state};
 
+	/* This function will try to connect to the legacy lxc-monitord state
+	 * server and only exists for backwards compatibility.
+	 */
+	lxc_monitor_send_state(name, state, handler->lxcpath);
+
 	process_lock();
 	/* Only set state under process lock held so that we don't cause
 	 * lxc_cmd_state_server() to miss a state.
@@ -394,11 +399,6 @@ int lxc_set_state(const char *name, struct lxc_handler *handler,
 	}
 	process_unlock();
 
-	/* This function will try to connect to the legacy lxc-monitord state
-	 * server and only exists for backwards compatibility.
-	 */
-	lxc_monitor_send_state(name, state, handler->lxcpath);
-
 	return 0;
 }
 


More information about the lxc-devel mailing list