Re: [LEDE-DEV] [PATCH 1/2] service: add func for string config change check

2018-02-11 Thread John Crispin

Hi

could you resend this with a description text ? I figured out what the 
patch does but it would be nice to have it as part of the commit history.


same for the group id patch please ...

    John


On 11/02/18 13:07, Yousong Zhou wrote:

Signed-off-by: Yousong Zhou 
---
  service/instance.c | 14 ++
  1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/service/instance.c b/service/instance.c
index 12c2efe..c3f8b56 100644
--- a/service/instance.c
+++ b/service/instance.c
@@ -588,6 +588,11 @@ instance_restart(struct service_instance *in)
uloop_timeout_set(>timeout, in->term_timeout * 1000);
  }
  
+static bool string_changed(const char *a, const char *b)

+{
+   return !((!a && !b) || (a && b && !strcmp(a, b)));
+}
+
  static bool
  instance_config_changed(struct service_instance *in, struct service_instance 
*in_new)
  {
@@ -615,14 +620,7 @@ instance_config_changed(struct service_instance *in, 
struct service_instance *in
if (in->gid != in_new->gid)
return true;
  
-	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)
+   if (string_changed(in->pidfile, in_new->pidfile))
return true;
  
  	if (in->respawn_retry != in_new->respawn_retry)



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


[LEDE-DEV] [PATCH 1/2] service: add func for string config change check

2018-02-11 Thread Yousong Zhou
Signed-off-by: Yousong Zhou 
---
 service/instance.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/service/instance.c b/service/instance.c
index 12c2efe..c3f8b56 100644
--- a/service/instance.c
+++ b/service/instance.c
@@ -588,6 +588,11 @@ instance_restart(struct service_instance *in)
uloop_timeout_set(>timeout, in->term_timeout * 1000);
 }
 
+static bool string_changed(const char *a, const char *b)
+{
+   return !((!a && !b) || (a && b && !strcmp(a, b)));
+}
+
 static bool
 instance_config_changed(struct service_instance *in, struct service_instance 
*in_new)
 {
@@ -615,14 +620,7 @@ instance_config_changed(struct service_instance *in, 
struct service_instance *in
if (in->gid != in_new->gid)
return true;
 
-   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)
+   if (string_changed(in->pidfile, in_new->pidfile))
return true;
 
if (in->respawn_retry != in_new->respawn_retry)
-- 
1.8.3.1


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