From 40ca88c1e06b1701fbc4707cc49071f2a9630cd2 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 30 Apr 2018 19:56:58 +0900 Subject: [PATCH] Fix systemd-assisted dbus activation sequence Change-Id: I6d3ddd8a9673957156f23f8fbd410adce5dd03cb Signed-off-by: Hyotaek Shim --- CMakeLists.txt | 1 + packaging/storaged.spec | 1 + src/core/main.c | 7 ++----- systemd/org.tizen.system.storage.service | 5 +++++ 4 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 systemd/org.tizen.system.storage.service diff --git a/CMakeLists.txt b/CMakeLists.txt index 04a4ef8..b83887c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,7 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${${PROJECT_NAME}_pkgs_LDFLAGS} "-ldl" "-l INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) INSTALL(FILES ${CMAKE_SOURCE_DIR}/conf/org.tizen.system.storage.conf DESTINATION /etc/dbus-1/system.d) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/systemd/org.tizen.system.storage.service DESTINATION /usr/share/dbus-1/system-services) INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/systemd/ DESTINATION lib/systemd/system FILES_MATCHING PATTERN "storaged.service") diff --git a/packaging/storaged.spec b/packaging/storaged.spec index 57dc13d..0a3a68d 100644 --- a/packaging/storaged.spec +++ b/packaging/storaged.spec @@ -134,6 +134,7 @@ systemctl daemon-reload %manifest %{name}.manifest %license LICENSE.Apache-2.0 %config %{_sysconfdir}/dbus-1/system.d/org.tizen.system.storage.conf +%{_datadir}/dbus-1/system-services/org.tizen.system.storage.service %{_unitdir}/multi-user.target.wants/storaged.service %{_unitdir}/storaged.service %{_bindir}/storaged diff --git a/src/core/main.c b/src/core/main.c index ffee3ea..365365f 100755 --- a/src/core/main.c +++ b/src/core/main.c @@ -58,11 +58,10 @@ static gboolean watchdog_cb(gpointer data) return G_SOURCE_CONTINUE; } -static gboolean storaged_notify(gpointer data) +static void dbus_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) { _I("sd_notify(READY=1)"); sd_notify(0, "READY=1"); - return G_SOURCE_REMOVE; } int main(int argc, char **argv) @@ -83,7 +82,7 @@ int main(int argc, char **argv) modules_init(NULL); - ret = dbus_handle_request_bus_name(handle, STORAGED_BUS_NAME, NULL, NULL); + ret = dbus_handle_request_bus_name(handle, STORAGED_BUS_NAME, dbus_name_acquired, NULL); if (ret <= 0) { _E("Fail to request bus name"); dbus_handle_check_owner_name(NULL, STORAGED_BUS_NAME); @@ -99,8 +98,6 @@ int main(int argc, char **argv) _E("aw_register failed"); } - g_idle_add(storaged_notify, NULL); - g_main_loop_run(loop); modules_deinit(NULL); diff --git a/systemd/org.tizen.system.storage.service b/systemd/org.tizen.system.storage.service new file mode 100644 index 0000000..d6127f7 --- /dev/null +++ b/systemd/org.tizen.system.storage.service @@ -0,0 +1,5 @@ +[D-BUS Service] +Name=org.tizen.system.storage +Exec=/bin/false +User=root +SystemdService=storaged.service -- 2.7.4