diff options
| author | Tim Nordell | 2025-10-15 20:52:04 +0000 |
|---|---|---|
| committer | Daniel Golle | 2026-03-14 00:29:08 +0000 |
| commit | 62654637114b68f16bfc10fbcc31bc075f92bf3a (patch) | |
| tree | 67e5f5c879628ce14b9ede262225a2d40df7e3d4 | |
| parent | 45bef92d049f9f31c1624ae59de5ca3546cf4289 (diff) | |
| download | procd-62654637114b68f16bfc10fbcc31bc075f92bf3a.tar.gz | |
service instance: Improve handling of watchdog config changes
When the ubus call "ubus call service watchdog" is used, it's expected
that the service might change its watchdog values during runtime when
it pets the watchdog. The instance restarting behavior was setup though
to restart the instance if these changed. This causes any service which
adjusts its watchdog to be restarted via "/etc/init.d/SERVICENAME start"
which is probably not what was intended.
Introduce a new variable, self_managed, if the service adjusted these
values at runtime so that a "start" doesn't cause the entire service to
restart.
Signed-off-by: Tim Nordell <tnordell@airgain.com>
(cherry picked from commit afa4391d9cbb0706bbae9c8345436fa6d99c3013)
| -rw-r--r-- | service/instance.c | 12 | ||||
| -rw-r--r-- | service/instance.h | 1 | ||||
| -rw-r--r-- | service/service.c | 5 |
3 files changed, 13 insertions, 5 deletions
diff --git a/service/instance.c b/service/instance.c index 21fa7ae..5e23fba 100644 --- a/service/instance.c +++ b/service/instance.c @@ -1035,10 +1035,10 @@ instance_config_changed(struct service_instance *in, struct service_instance *in if (in->jail.flags != in_new->jail.flags) return true; - if (in->watchdog.mode != in_new->watchdog.mode) + if (!in->watchdog.self_managed && in->watchdog.mode != in_new->watchdog.mode) return true; - if (in->watchdog.freq != in_new->watchdog.freq) + if (!in->watchdog.self_managed && in->watchdog.freq != in_new->watchdog.freq) return true; return false; @@ -1508,9 +1508,11 @@ instance_config_move(struct service_instance *in, struct service_instance *in_sr in->respawn_timeout = in_src->respawn_timeout; in->reload_signal = in_src->reload_signal; in->term_timeout = in_src->term_timeout; - in->watchdog.mode = in_src->watchdog.mode; - in->watchdog.freq = in_src->watchdog.freq; - // Note: in->watchdog.timeout is in a linked list; do not copy + if (!in->watchdog.self_managed) { + // Note: in->watchdog.timeout is in a linked list; do not copy + in->watchdog.mode = in_src->watchdog.mode; + in->watchdog.freq = in_src->watchdog.freq; + } in->name = in_src->name; in->nice = in_src->nice; in->trace = in_src->trace; diff --git a/service/instance.h b/service/instance.h index 215cbc7..22a96d6 100644 --- a/service/instance.h +++ b/service/instance.h @@ -54,6 +54,7 @@ typedef enum instance_watchdog { } instance_watchdog_mode_t; struct watchdog { + bool self_managed; instance_watchdog_mode_t mode; uint32_t freq; struct uloop_timeout timeout; diff --git a/service/service.c b/service/service.c index cf8192c..579be27 100644 --- a/service/service.c +++ b/service/service.c @@ -994,6 +994,11 @@ service_handle_watchdog(struct ubus_context *ctx, struct ubus_object *obj, ubus_send_reply(ctx, req, b.head); + // If the service adjusts the mode or timeout, mark it as self managed + // so that it doesn't get restarted with a new /etc/init.d/SERVICE start + if (tb[SERVICE_WATCHDOG_MODE] || tb[SERVICE_WATCHDOG_TIMEOUT]) + in->watchdog.self_managed = true; + return UBUS_STATUS_OK; } |