aboutsummaryrefslogtreecommitdiffstats
path: root/src/interfaces/logind
diff options
context:
space:
mode:
authorkremlin <ian@kremlin.cc>2014-08-05 10:18:51 +0800
committerkremlin <ian@kremlin.cc>2014-08-05 10:18:51 +0800
commit341587dbd94b8845b91baef896d9da2693df19bb (patch)
tree1caa4744472945fa20d75942b34c7d281c9f80b5 /src/interfaces/logind
parent509599f043fd77c5eee595ebce117ff9e11a5324 (diff)
downloadsystembsd-341587dbd94b8845b91baef896d9da2693df19bb.tar
systembsd-341587dbd94b8845b91baef896d9da2693df19bb.tar.gz
systembsd-341587dbd94b8845b91baef896d9da2693df19bb.tar.bz2
systembsd-341587dbd94b8845b91baef896d9da2693df19bb.tar.lz
systembsd-341587dbd94b8845b91baef896d9da2693df19bb.tar.xz
systembsd-341587dbd94b8845b91baef896d9da2693df19bb.tar.zst
systembsd-341587dbd94b8845b91baef896d9da2693df19bb.zip
(5) fix foo_mem_clean() functions to avoid race cond.
mem_clean functions previously free()'d our pointer array without first checking that the name/interface had properly been unexported from dbus. checking first better guarantees all operations implicating that date have ceased, and that it is safe to go ahead and stop the GMainLoop before immediately returning. this causes the code just after the main_loop_begin() call to start functioning, in our case the actual free() calls (which are now *absolutley* safe to call)
Diffstat (limited to 'src/interfaces/logind')
-rw-r--r--src/interfaces/logind/logind.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/interfaces/logind/logind.c b/src/interfaces/logind/logind.c
index b08db9f..78775cf 100644
--- a/src/interfaces/logind/logind.c
+++ b/src/interfaces/logind/logind.c
@@ -123,8 +123,14 @@ static void logind_on_name_lost(GDBusConnection *conn,
* this stops our GMainLoop sfaely before letting main() return */
void logind_mem_clean() {
- g_ptr_array_foreach(logind_freeable, (GFunc) g_free, NULL);
- g_ptr_array_free(logind_freeable, TRUE);
+ g_printf("exiting...\n");
+
+ if(dbus_interface_exported)
+ g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(logind_interf));
+
+ if(g_main_loop_is_running(logind_loop))
+ g_main_loop_quit(logind_loop);
+
}
int main() {