Handle the pending dbus calls before termination
[platform/core/connectivity/bluetooth-frwk.git] / bt-service-adaptation / services / bt-request-handler.c
index d1d1203..752f5de 100644 (file)
@@ -4269,6 +4269,19 @@ gboolean _is_name_acquired(void)
        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;
@@ -4318,15 +4331,12 @@ void _bt_service_unregister(void)
                        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);
        }
 }