service: reorder sd_notify() handling a bit
authorLennart Poettering <lennart@poettering.net>
Mon, 13 Nov 2017 17:06:09 +0000 (18:06 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 27 Nov 2017 15:59:52 +0000 (16:59 +0100)
Let's keep handling of WATCHDOG= and WATCHDOG_USEC= together. No
functional changes.

man/sd_notify.xml
src/core/service.c
src/systemd/sd-daemon.h

index 078f1ff..4a5e087 100644 (file)
         watchdog is enabled. </para></listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term>WATCHDOG_USEC=…</term>
+
+        <listitem><para>Reset <varname>watchdog_usec</varname> value during runtime.
+        Notice that this is not available when using <function>sd_event_set_watchdog()</function>
+        or <function>sd_watchdog_enabled()</function>.
+        Example : <literal>WATCHDOG_USEC=20000000</literal></para></listitem>
+      </varlistentry>
 
       <varlistentry>
         <term>FDSTORE=1</term>
         restrictions, it is ignored.</para></listitem>
       </varlistentry>
 
-      <varlistentry>
-        <term>WATCHDOG_USEC=…</term>
-
-        <listitem><para>Reset <varname>watchdog_usec</varname> value during runtime.
-        Notice that this is not available when using <function>sd_event_set_watchdog()</function>
-        or <function>sd_watchdog_enabled()</function>.
-        Example : <literal>WATCHDOG_USEC=20000000</literal></para></listitem>
-      </varlistentry>
-
     </variablelist>
 
     <para>It is recommended to prefix variable names that are not
index add054b..0beb25b 100644 (file)
@@ -3457,6 +3457,15 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags, FDSet *fds)
         if (strv_find(tags, "WATCHDOG=1"))
                 service_reset_watchdog(s);
 
+        e = strv_find_startswith(tags, "WATCHDOG_USEC=");
+        if (e) {
+                usec_t watchdog_override_usec;
+                if (safe_atou64(e, &watchdog_override_usec) < 0)
+                        log_unit_warning(u, "Failed to parse WATCHDOG_USEC=%s", e);
+                else
+                        service_reset_watchdog_timeout(s, watchdog_override_usec);
+        }
+
         if (strv_find(tags, "FDSTORE=1")) {
                 const char *name;
 
@@ -3469,15 +3478,6 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags, FDSet *fds)
                 service_add_fd_store_set(s, fds, name);
         }
 
-        e = strv_find_startswith(tags, "WATCHDOG_USEC=");
-        if (e) {
-                usec_t watchdog_override_usec;
-                if (safe_atou64(e, &watchdog_override_usec) < 0)
-                        log_unit_warning(u, "Failed to parse WATCHDOG_USEC=%s", e);
-                else
-                        service_reset_watchdog_timeout(s, watchdog_override_usec);
-        }
-
         /* Notify clients about changed status or main pid */
         if (notify_dbus)
                 unit_add_to_dbus_queue(u);
index 61cfdd8..54e8256 100644 (file)
@@ -204,17 +204,17 @@ int sd_is_mq(int fd, const char *path);
                   timestamps to detect failed services. Also see
                   sd_watchdog_enabled() below.
 
+     WATCHDOG_USEC=...
+                  Reset watchdog_usec value during runtime.
+                  To reset watchdog_usec value, start the service again.
+                  Example: "WATCHDOG_USEC=20000000"
+
      FDSTORE=1    Store the file descriptors passed along with the
                   message in the per-service file descriptor store,
                   and pass them to the main process again on next
                   invocation. This variable is only supported with
                   sd_pid_notify_with_fds().
 
-     WATCHDOG_USEC=...
-                  Reset watchdog_usec value during runtime.
-                  To reset watchdog_usec value, start the service again.
-                  Example: "WATCHDOG_USEC=20000000"
-
   Daemons can choose to send additional variables. However, it is
   recommended to prefix variable names not listed above with X_.