From eca4f07c51afa44844f3cc988073989e9d96a57b Mon Sep 17 00:00:00 2001 From: Michal Sekletar Date: Mon, 15 Jan 2018 16:21:11 +0100 Subject: [PATCH] systemd: make dbus-daemon service of type "notify" Use systemd's sd_notify() API in order tell systemd exactly when we are able to accept connections from systemd and other bus clients. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104641 Signed-off-by: Michal Sekletar --- bus/dbus.service.in | 1 + bus/main.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/bus/dbus.service.in b/bus/dbus.service.in index ca0b7e96..3db9b0b1 100644 --- a/bus/dbus.service.in +++ b/bus/dbus.service.in @@ -4,6 +4,7 @@ Documentation=man:dbus-daemon(1) Requires=dbus.socket [Service] +Type=notify ExecStart=@EXPANDED_BINDIR@/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only ExecReload=@EXPANDED_BINDIR@/dbus-send --print-reply --system --type=method_call --dest=org.freedesktop.DBus / org.freedesktop.DBus.ReloadConfig OOMScoreAdjust=-900 diff --git a/bus/main.c b/bus/main.c index b3fcddd0..b4e9ba3f 100644 --- a/bus/main.c +++ b/bus/main.c @@ -46,6 +46,10 @@ #include #endif +#ifdef HAVE_SYSTEMD +#include +#endif + static BusContext *context; #ifdef DBUS_UNIX @@ -715,6 +719,14 @@ main (int argc, char **argv) _dbus_set_signal_handler (SIGHUP, signal_handler); #endif /* DBUS_UNIX */ +#ifdef HAVE_SYSTEMD + (void) sd_notifyf(1, + "READY=1\n" + "STATUS=Processing connections to D-Bus...\n" + "MAINPID=%lu", + (unsigned long) getpid()); +#endif + _dbus_verbose ("We are on D-Bus...\n"); _dbus_loop_run (bus_context_get_loop (context)); -- 2.14.3