return name_acquired;
}
+void _bt_service_unref_connection(void)
+{
+ BT_INFO("+");
+
+ if (bt_service_conn) {
+ g_dbus_connection_flush_sync(bt_service_conn, NULL, NULL);
+ g_object_unref(bt_service_conn);
+ bt_service_conn = NULL;
+ }
+
+ BT_INFO("-");
+}
+
int _bt_service_register(void)
{
GDBusConnection *conn;
owner_sig_id = 0;
}
- __bt_service_register_object(bt_service_conn, NULL, FALSE);
- if (bt_service_conn) {
- g_object_unref(bt_service_conn);
- bt_service_conn = NULL;
- }
if (owner_id > 0) {
g_bus_unown_name(owner_id);
owner_id = 0;
}
+
+ __bt_service_register_object(bt_service_conn, NULL, FALSE);
}
}
return FALSE;
}
-gboolean _bt_reliable_terminate_service(gpointer user_data)
+static gboolean __bt_main_loop_quit_idle_cb(gpointer user_data)
{
_bt_deinit_proxys();
_bt_deinit_service_event_sender();
- _bt_service_unregister();
-
terminated = TRUE;
- BT_INFO_C("### Terminating the bt-service daemon");
+ BT_INFO_C("Terminating the bt-service daemon");
- if (main_loop != NULL)
+ if (main_loop != NULL) {
g_main_loop_quit(main_loop);
- else
+ } else {
+ BT_ERR("main_loop == NULL");
exit(0);
+ }
+
+ return FALSE;
+}
+
+gboolean _bt_reliable_terminate_service(gpointer user_data)
+{
+ _bt_service_unregister();
+
+ /* Handle remaining pending requests finally by using g_idle_add()
+ again without well-known name. */
+ g_idle_add((GSourceFunc)__bt_main_loop_quit_idle_cb, NULL);
return FALSE;
}
bluetooth_plugin_deinit();
+ _bt_service_unref_connection();
+
if (main_loop != NULL)
g_main_loop_unref(main_loop);