summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Evensen2019-04-06 12:28:30 +0000
committerHans Dedecker2019-04-07 19:20:55 +0000
commitbaaf38c5e540b23ba086d94743de860b60c37161 (patch)
tree5a14ec33c6d9d74cac6e0dec3576ff6173ca4114
parentd876d1ca221112674a7e9a6ba0fee65b947fdfa7 (diff)
downloadprocd-baaf38c5e540b23ba086d94743de860b60c37161.tar.gz
procd: instance: Support deleting stopped instances
procd currently does not support deleting a stopped instance. The reason is that we return in instance_stop(), if pending is set to false. This patch adds a new function, instance_delete(), which does the necessary clean-up of an instance. instance_delete() is called before we return in instance_stop(), as well as when a process that should not be restarted has exited in instance_exit(). Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
-rw-r--r--service/instance.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/service/instance.c b/service/instance.c
index a5742b7..3512f66 100644
--- a/service/instance.c
+++ b/service/instance.c
@@ -519,6 +519,16 @@ instance_timeout(struct uloop_timeout *t)
}
static void
+instance_delete(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)
{
struct service_instance *in;
@@ -539,13 +549,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_delete(in);
} else if (in->restart) {
instance_start(in);
} else if (in->respawn) {
@@ -569,8 +574,11 @@ instance_exit(struct uloop_process *p, int ret)
void
instance_stop(struct service_instance *in, bool halt)
{
- if (!in->proc.pending)
+ if (!in->proc.pending) {
+ if (halt)
+ instance_delete(in);
return;
+ }
in->halt = halt;
in->restart = in->respawn = false;
kill(in->proc.pid, SIGTERM);