From: Lennart Poettering Date: Mon, 13 Nov 2017 16:44:00 +0000 (+0100) Subject: core: only log about sd_notify() message contents, when debug logging is on X-Git-Tag: v236~105^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9711848ff1fe8d74c7d100e4714c4dac30923e74;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/core/service.c b/src/core/service.c index 672eaa9199b..b36da3ad15b 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=");