diff options
author | Yousong Zhou <yszhou4tech@gmail.com> | 2018-02-11 17:17:08 +0800 |
---|---|---|
committer | Yousong Zhou <yszhou4tech@gmail.com> | 2018-03-28 17:29:49 +0800 |
commit | 3db4e6d21ef85c3fbf1d7e0ae36bd1f039fec255 (patch) | |
tree | 0ad6525aac1654971e4ace567f81a56d4045189d /service | |
parent | c3faabeb635ce515b831afb2e87d9bb241991907 (diff) | |
download | procd-3db4e6d21ef85c3fbf1d7e0ae36bd1f039fec255.tar.gz |
service: add func for string config change check
To also prepare for following commits introducing more string value
change detection
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Diffstat (limited to 'service')
-rw-r--r-- | service/instance.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/service/instance.c b/service/instance.c index ecbb6ea..74c47fa 100644 --- a/service/instance.c +++ b/service/instance.c @@ -587,6 +587,11 @@ instance_restart(struct service_instance *in) uloop_timeout_set(&in->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) { @@ -614,14 +619,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) |