It's give ability to stop respawn of instance
which crashes in the beginning

Signed-off-by: Pavel Merzlyakov <pavel.merzlya...@gmail.com>
---
 service/instance.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/service/instance.c b/service/instance.c
index ecbb6ea..e2f0ee3 100644
--- a/service/instance.c
+++ b/service/instance.c
@@ -511,6 +511,16 @@ instance_timeout(struct uloop_timeout *t)
                instance_start(in);
 }
 
+static void
+instance_stopped(struct service_instance *in)
+{
+       struct service *s = in->srv;
+
+       avl_delete(&s->instances.avl, &in->node.avl);
+       instance_free(in);
+       service_stopped(s);
+}
+
 static void
 instance_exit(struct uloop_process *p, int ret)
 {
@@ -532,13 +542,8 @@ instance_exit(struct uloop_process *p, int ret)
                instance_removepid(in);
                if (in->restart)
                        instance_start(in);
-               else {
-                       struct service *s = in->srv;
-
-                       avl_delete(&s->instances.avl, &in->node.avl);
-                       instance_free(in);
-                       service_stopped(s);
-               }
+               else
+                       instance_stopped(in);
        } else if (in->restart) {
                instance_start(in);
        } else if (in->respawn) {
@@ -563,7 +568,7 @@ void
 instance_stop(struct service_instance *in, bool halt)
 {
        if (!in->proc.pending)
-               return;
+               return instance_stopped(in);
        in->halt = halt;
        in->restart = in->respawn = false;
        kill(in->proc.pid, SIGTERM);
-- 
2.16.1


_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to