]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: only log about sd_notify() message contents, when debug logging is on
authorLennart Poettering <lennart@poettering.net>
Mon, 13 Nov 2017 16:44:00 +0000 (17:44 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 27 Nov 2017 15:39:43 +0000 (16:39 +0100)
Let's optimize things a bit for the non-debug case. No change in
behaviour.

Main reason to do this is not so much the speed benefit though, but
merely to isolate the code from its surroundings more.

src/core/service.c

index 672eaa9199b3aa563572dfad48254da96f37298c..b36da3ad15b674d4773eed92012cda290982c047 100644 (file)
@@ -3312,14 +3312,11 @@ static int service_dispatch_watchdog(sd_event_source *source, usec_t usec, void
 
 static void service_notify_message(Unit *u, pid_t pid, char **tags, FDSet *fds) {
         Service *s = SERVICE(u);
-        _cleanup_free_ char *cc = NULL;
         bool notify_dbus = false;
         const char *e;
 
         assert(u);
 
-        cc = strv_join(tags, ", ");
-
         if (s->notify_access == NOTIFY_NONE) {
                 log_unit_warning(u, "Got notification message from PID "PID_FMT", but reception is disabled.", pid);
                 return;
@@ -3340,8 +3337,14 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags, FDSet *fds)
                 else
                         log_unit_warning(u, "Got notification message from PID "PID_FMT", but reception only permitted for main PID and control PID which are currently not known", pid);
                 return;
-        } else
+        }
+
+        if (log_get_max_level() >= LOG_DEBUG) {
+                _cleanup_free_ char *cc = NULL;
+
+                cc = strv_join(tags, ", ");
                 log_unit_debug(u, "Got notification message from PID "PID_FMT" (%s)", pid, isempty(cc) ? "n/a" : cc);
+        }
 
         /* Interpret MAINPID= */
         e = strv_find_startswith(tags, "MAINPID=");