Re: [OpenWrt-Devel] [PATCH] procd: instance: Support deleting stopped instances

2019-04-06 Thread Hans Dedecker
On Sat, Apr 6, 2019 at 12:27 PM Kristian Evensen
 wrote:
>
> Hi Hans,
>
> On Thu, Apr 4, 2019 at 10:59 PM Hans Dedecker  wrote:
> > instance_delete should only be called when halt is set to true similar
> > as in instance_exit
>
> Thanks for the feedback. Just so I make sure I understand correctly,
> do you mean that the conditional should look something like this?
>
>  577 if (!in->proc.pending) {
>  578 if (halt)
>  579 instance_delete(in);
>  580 return;
>  581 }
Indeed I meant there should be a conditional halt check before calling
instance_delete

Hans
>
> BR,
> Kristian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] procd: instance: Support deleting stopped instances

2019-04-06 Thread Kristian Evensen
Hi Hans,

On Thu, Apr 4, 2019 at 10:59 PM Hans Dedecker  wrote:
> instance_delete should only be called when halt is set to true similar
> as in instance_exit

Thanks for the feedback. Just so I make sure I understand correctly,
do you mean that the conditional should look something like this?

 577 if (!in->proc.pending) {
 578 if (halt)
 579 instance_delete(in);
 580 return;
 581 }

BR,
Kristian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] procd: instance: Support deleting stopped instances

2019-04-04 Thread Hans Dedecker
On Wed, Mar 13, 2019 at 4:44 PM Kristian Evensen
 wrote:
>
> 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 
> ---
>  service/instance.c | 23 +++
>  1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/service/instance.c b/service/instance.c
> index a5742b7..78ac540 100644
> --- a/service/instance.c
> +++ b/service/instance.c
> @@ -518,6 +518,16 @@ instance_timeout(struct uloop_timeout *t)
> instance_start(in);
>  }
>
> +static void
> +instance_delete(struct service_instance *in)
> +{
> +   struct service *s = in->srv;
> +
> +   avl_delete(>instances.avl, >node.avl);
> +   instance_free(in);
> +   service_stopped(s);
> +}
> +
>  static void
>  instance_exit(struct uloop_process *p, int ret)
>  {
> @@ -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(>instances.avl, >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,10 @@ 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) {
> +   instance_delete(in);
instance_delete should only be called when halt is set to true similar
as in instance_exit

Hans
> return;
> +   }
> in->halt = halt;
> in->restart = in->respawn = false;
> kill(in->proc.pid, SIGTERM);
> --
> 2.19.1
>
>
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] procd: instance: Support deleting stopped instances

2019-03-13 Thread Kristian Evensen
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 
---
 service/instance.c | 23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/service/instance.c b/service/instance.c
index a5742b7..78ac540 100644
--- a/service/instance.c
+++ b/service/instance.c
@@ -518,6 +518,16 @@ instance_timeout(struct uloop_timeout *t)
instance_start(in);
 }
 
+static void
+instance_delete(struct service_instance *in)
+{
+   struct service *s = in->srv;
+
+   avl_delete(>instances.avl, >node.avl);
+   instance_free(in);
+   service_stopped(s);
+}
+
 static void
 instance_exit(struct uloop_process *p, int ret)
 {
@@ -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(>instances.avl, >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,10 @@ 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) {
+   instance_delete(in);
return;
+   }
in->halt = halt;
in->restart = in->respawn = false;
kill(in->proc.pid, SIGTERM);
-- 
2.19.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel