From 9711848ff1fe8d74c7d100e4714c4dac30923e74 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 13 Nov 2017 17:44:00 +0100 Subject: [PATCH] core: only log about sd_notify() message contents, when debug logging is on 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 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/service.c b/src/core/service.c index 672eaa9199..b36da3ad15 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -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="); -- 2.25.1