@@ -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);
It's give ability to stop respawn of instance which crashes in the beginning Signed-off-by: Pavel Merzlyakov <pavel.merzlyakov@gmail.com> --- service/instance.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)