core: Apply systemd-based dbus activation 48/210148/3
authorHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 15 Jul 2019 06:13:35 +0000 (15:13 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Tue, 16 Jul 2019 08:12:10 +0000 (17:12 +0900)
To activate PASS service immediately when other service requests the
dbus methods of it, this patch applies systemd-based dbus
activation. In addition, to announce PASS startup completion to
systemd, this patch adds notification through 'sd_notify()' call.
Without it, systemd will block PASS activation.

Change-Id: I4bfd6fce55d83aee646405af7bafbc650cb177e5
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
CMakeLists.txt
packaging/pass.spec
src/core/main.c
systemd/org.tizen.system.pass.service [new file with mode: 0644]
systemd/pass.service

index a7521d4..78ef96c 100644 (file)
@@ -52,6 +52,7 @@ SET(PKG_MODULES
        gio-2.0
        gio-unix-2.0
        libudev
+       libsystemd
 )
 
 INCLUDE(FindPkgConfig)
@@ -99,6 +100,7 @@ INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/${PROJECT_NAME}.conf DESTINATION /etc/dbus-1/system.d)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pass-pmqos.conf DESTINATION /etc/pass)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pass-thermal.conf DESTINATION /etc/pass)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/systemd/org.tizen.system.pass.service DESTINATION /usr/share/dbus-1/system-services)
 
 CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
index da6d2cf..a23bf98 100644 (file)
@@ -23,6 +23,7 @@ BuildRequires:  pkgconfig(gio-unix-2.0)
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(gmock)
 BuildRequires:  pkgconfig(libudev)
+BuildRequires:  pkgconfig(libsystemd)
 
 %description
 PASS  (Power-Aware System Service)
@@ -102,6 +103,7 @@ systemctl daemon-reload
 %{_bindir}/%{daemon_name}
 %{_unitdir}/delayed.target.wants/%{daemon_name}.service
 %{_unitdir}/%{daemon_name}.service
+%{_datadir}/dbus-1/system-services/org.tizen.system.pass.service
 
 %files -n %{hal_name}
 %defattr(-,root,root,-)
index 7d8176e..03bc85a 100644 (file)
@@ -22,6 +22,7 @@
 #include <string.h>
 #include <gio/gio.h>
 #include <sys/reboot.h>
+#include <systemd/sd-daemon.h>
 
 #include <pass/common.h>
 #include <pass/device-notifier.h>
@@ -43,6 +44,12 @@ static void sig_usr1(int signo)
        g_main_loop_quit(g_mainloop);
 }
 
+static void pass_name_acquired_cb(GDBusConnection *connection,
+                               const gchar *name, gpointer user_data)
+{
+       sd_notify(0, "READY=1");
+}
+
 static int late_init(void)
 {
        int ret;
@@ -50,7 +57,8 @@ static int late_init(void)
        signal(SIGTERM, sig_quit);
        signal(SIGUSR1, sig_usr1);
 
-       ret = pass_gdbus_get_name(PASS_DBUS_CORE, DBUS_PASS_BUS_NAME, NULL);
+       ret = pass_gdbus_get_name(PASS_DBUS_CORE,
+                               DBUS_PASS_BUS_NAME, pass_name_acquired_cb);
        if (ret < 0)
                return ret;
 
diff --git a/systemd/org.tizen.system.pass.service b/systemd/org.tizen.system.pass.service
new file mode 100644 (file)
index 0000000..014396c
--- /dev/null
@@ -0,0 +1,4 @@
+[D-BUS Service]
+Name=org.tizen.system.pass
+Exec=/bin/false
+SystemdService=pass.service
index fe35ca3..13b8bcf 100644 (file)
@@ -2,6 +2,7 @@
 Description=PASS daemon
 
 [Service]
+Type=notify
 SmackProcessLabel=System
 ExecStart=/usr/bin/pass
 Restart=always