Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions service/instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,10 +1040,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;
Expand Down Expand Up @@ -1517,9 +1517,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;
in->watchdog.timeout = in_src->watchdog.timeout;
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;
Expand Down
1 change: 1 addition & 0 deletions service/instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,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;
Expand Down
5 changes: 5 additions & 0 deletions service/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,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;
}

Expand Down
Loading