chiark / gitweb /
service: make sure the watchdog timer is not restarted while stopping
[elogind.git] / src / core / service.c
index 9e46dbae9478b7aab8177018c395da2e8cd3f68e..baddc5ade4cd05cff8c8969646710e9c1af5cb4a 100644 (file)
@@ -1550,7 +1550,7 @@ static void service_set_state(Service *s, ServiceState state) {
                 service_connection_unref(s);
         }
 
-        if (state == SERVICE_STOP)
+        if (state == SERVICE_STOP || state == SERVICE_STOP_SIGTERM)
                 service_stop_watchdog(s);
 
         /* For the inactive states unit_notify() will trim the cgroup,
@@ -2939,13 +2939,13 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
                                 f = SERVICE_SUCCESS;
                 }
 
-                log_struct(f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
+                log_struct_unit(f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
+                           u->id,
                            "MESSAGE=%s: main process exited, code=%s, status=%i/%s",
                                   u->id, sigchld_code_to_string(code), status,
                                   strna(code == CLD_EXITED
                                         ? exit_status_to_string(status, EXIT_STATUS_FULL)
                                         : signal_to_string(status)),
-                           "UNIT=%s", u->id,
                            "EXIT_CODE=%s", sigchld_code_to_string(code),
                            "EXIT_STATUS=%i", status,
                            NULL);
@@ -3400,7 +3400,8 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
         if (strv_find(tags, "WATCHDOG=1")) {
                 log_debug_unit(u->id,
                                "%s: got WATCHDOG=1", u->id);
-                service_reset_watchdog(s);
+                if (dual_timestamp_is_set(&s->watchdog_timestamp))
+                        service_reset_watchdog(s);
         }
 
         /* Notify clients about changed status or main pid */
@@ -3832,13 +3833,15 @@ DEFINE_STRING_TABLE_LOOKUP(start_limit_action, StartLimitAction);
 
 const UnitVTable service_vtable = {
         .object_size = sizeof(Service),
-        .exec_context_offset = offsetof(Service, exec_context),
 
         .sections =
                 "Unit\0"
                 "Service\0"
                 "Install\0",
 
+        .exec_context_offset = offsetof(Service, exec_context),
+        .exec_section = "Service",
+
         .init = service_init,
         .done = service_done,
         .load = service_load,