From: INSUN PYO Date: Tue, 22 Dec 2020 07:47:51 +0000 (+0900) Subject: Call sd_notify(0, "STOPPING=1") when exiting X-Git-Tag: submit/tizen/20210105.091325^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7efe14c741c436e6257cbe0bd893a225d68c41e8;p=platform%2Fcore%2Fconnectivity%2Fstc-iptables.git Call sd_notify(0, "STOPPING=1") when exiting When well-known name disappears, systemd sends SIGTERM to the service associated with the well-known name. To prevent this, call sd_notify(0, "STOPPING=1") before unowing the name. Journal log =================================================================================================== sh-3.2# systemctl status stc-iptables.service ● stc-iptables.service - Smart Traffic Control Iptables Loaded: loaded (/usr/lib/systemd/system/stc-iptables.service; disabled; vendor preset: enabled) Active: inactive (dead) since Thu 2015-01-01 09:35:58 KST; 6s ago Process: 367 ExecStart=/usr/bin/stc-iptables (code=killed, signal=TERM) Main PID: 367 (code=killed, signal=TERM) Jan 01 09:35:36 localhost systemd[1]: Starting Smart Traffic Control Iptables... Jan 01 09:35:38 localhost systemd[1]: Started Smart Traffic Control Iptables. Jan 01 09:35:58 localhost systemd[1]: stc-iptables.service: Succeeded. =================================================================================================== Change-Id: I43434c79d8b3474917c9d96b6bd6ef0fa7b8571a --- diff --git a/packaging/stc-iptables.spec b/packaging/stc-iptables.spec index 8514b96..2f61e39 100644 --- a/packaging/stc-iptables.spec +++ b/packaging/stc-iptables.spec @@ -13,6 +13,7 @@ BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(gio-unix-2.0) BuildRequires: pkgconfig(libiptc) BuildRequires: pkgconfig(libip6tc) +BuildRequires: pkgconfig(libsystemd) %if 0%{?gtests:1} BuildRequires: pkgconfig(dlog) diff --git a/resources/systemd/stc-iptables.service b/resources/systemd/stc-iptables.service index 093db75..1393b17 100755 --- a/resources/systemd/stc-iptables.service +++ b/resources/systemd/stc-iptables.service @@ -11,6 +11,7 @@ SmackProcessLabel=System ExecStart=/usr/bin/stc-iptables Capabilities=cap_net_bind_service,cap_net_raw,cap_net_admin=i SecureBits=keep-caps +NotifyAccess=main [Install] WantedBy=multi-user.target diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 75197c2..aa94001 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,6 +4,7 @@ SET(REQUIRES_LIST ${REQUIRES_LIST} ${COMMON_DEPS} libiptc libip6tc + libsystemd ) INCLUDE(FindPkgConfig) diff --git a/src/stc-iptables-gdbus.c b/src/stc-iptables-gdbus.c index b966726..e95da6f 100755 --- a/src/stc-iptables-gdbus.c +++ b/src/stc-iptables-gdbus.c @@ -18,6 +18,7 @@ #include "stc-iptables.h" #include "stc-iptables-gdbus.h" #include "stc-iptables-util.h" +#include static gboolean __stc_iptables_gdbus_manager_init(stc_iptables_s *stc_iptables) { @@ -245,6 +246,7 @@ void stc_iptables_gdbus_deinit(gpointer stc_data) stc_iptables_s *stc_iptables = (stc_iptables_s *)stc_data; + sd_notify(0, "STOPPING=1"); g_bus_unown_name(stc_iptables->gdbus_owner_id); stc_iptables->manager_obj = NULL;