[LEDE-DEV,2/2] procd: Copy missing attr/cfg to new instance

Message ID 20180322170123.22269-3-pavel.merzlyakov@gmail.com
State New
Headers show
Series
  • [LEDE-DEV,1/2] procd: Fix respawn after restart of instance
Related show

Commit Message

Pavel Merzlyakov March 22, 2018, 5:01 p.m.
In case when we (async) stop instance
and then start it again while it not actually killed,
we just update config of old instance without remake (del and new)
so we should update/move all attr/cfg of instance

Signed-off-by: Pavel Merzlyakov <pavel.merzlyakov@gmail.com>
---
 service/instance.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 47 insertions(+), 2 deletions(-)

Patch

diff --git a/service/instance.c b/service/instance.c
index 5a14f82..ab949df 100644
--- a/service/instance.c
+++ b/service/instance.c
@@ -593,18 +593,35 @@  instance_config_changed(struct service_instance *in, struct service_instance *in
 	if (!in->valid)
 		return true;
 
+	if (!blob_attr_equal(in->trigger, in_new->trigger))
+		return true;
+
 	if (!blob_attr_equal(in->command, in_new->command))
 		return true;
 
 	if (!blobmsg_list_equal(&in->env, &in_new->env))
 		return true;
 
+	if (!blobmsg_list_equal(&in->data, &in_new->data))
+		return true;
+
 	if (!blobmsg_list_equal(&in->netdev, &in_new->netdev))
 		return true;
 
 	if (!blobmsg_list_equal(&in->file, &in_new->file))
 		return true;
 
+	if (in->name && in_new->name)
+		if (strcmp(in->name, in_new->name))
+			return true;
+	if (in->name && !in_new->name)
+		return true;
+	if (!in->name && in_new->name)
+		return true;
+
+	if (in->trace != in_new->trace)
+		return true;
+
 	if (in->nice != in_new->nice)
 		return true;
 
@@ -617,13 +634,13 @@  instance_config_changed(struct service_instance *in, struct service_instance *in
 	if (in->pidfile && in_new->pidfile)
 		if (strcmp(in->pidfile, in_new->pidfile))
 			return true;
-
 	if (in->pidfile && !in_new->pidfile)
 		return true;
-
 	if (!in->pidfile && in_new->pidfile)
 		return true;
 
+	if (in->respawn != in_new->respawn)
+		return true;
 	if (in->respawn_retry != in_new->respawn_retry)
 		return true;
 	if (in->respawn_threshold != in_new->respawn_threshold)
@@ -640,6 +657,26 @@  instance_config_changed(struct service_instance *in, struct service_instance *in
 	if (!blobmsg_list_equal(&in->errors, &in_new->errors))
 		return true;
 
+	if (in->has_jail != in_new->has_jail)
+		return true;
+
+	if (in->reload_signal != in_new->reload_signal)
+		return true;
+
+	if (in->no_new_privs != in_new->no_new_privs)
+		return true;
+
+	if (in->term_timeout != in_new->term_timeout)
+		return true;
+
+	if (in->seccomp && in_new->seccomp)
+		if (strcmp(in->seccomp, in_new->seccomp))
+			return true;
+	if (in->seccomp && !in_new->seccomp)
+		return true;
+	if (!in->seccomp && in_new->seccomp)
+		return true;
+
 	return false;
 }
 
@@ -951,6 +988,14 @@  instance_config_move(struct service_instance *in, struct service_instance *in_sr
 	in->name = in_src->name;
 	in->trace = in_src->trace;
 	in->node.avl.key = in_src->node.avl.key;
+	in->nice = in_src->nice;
+	in->uid = in_src->uid;
+	in->gid = in_src->gid;
+	in->has_jail = in_src->has_jail;
+	in->reload_signal = in_src->reload_signal;
+	in->no_new_privs = in_src->no_new_privs;
+	in->term_timeout = in_src->term_timeout;
+	in->seccomp = in_src->seccomp;
 
 	free(in->config);
 	in->config = in_src->config;