adv_monitor: Fix return type of RegisterMonitor() method
authorMiao-chen Chou <mcchou@chromium.org>
Sat, 31 Oct 2020 00:52:54 +0000 (17:52 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:33 +0000 (19:08 +0530)
This modifies the D-Bus call return type to be asynchronous for
RegisterMonitor() method call.

The following test was performed:
- Enter bluetoothctl, exit the console and re-enter the console without
AlreadyExist error for RegisterMonitor() upon bring-up of the console.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/adv_monitor.c

index ed29d8f..442c83c 100644 (file)
@@ -693,6 +693,8 @@ static struct adv_monitor_app *app_create(DBusConnection *conn,
 
        app->monitors = queue_new();
 
+       app->reg = dbus_message_ref(msg);
+
        g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app);
 
        /* Note that any property changes on a monitor object would not affect
@@ -704,8 +706,6 @@ static struct adv_monitor_app *app_create(DBusConnection *conn,
 
        g_dbus_client_set_ready_watch(app->client, app_ready_cb, app);
 
-       app->reg = dbus_message_ref(msg);
-
        return app;
 }
 
@@ -799,7 +799,7 @@ static DBusMessage *unregister_monitor(DBusConnection *conn,
 }
 
 static const GDBusMethodTable adv_monitor_methods[] = {
-       { GDBUS_EXPERIMENTAL_METHOD("RegisterMonitor",
+       { GDBUS_EXPERIMENTAL_ASYNC_METHOD("RegisterMonitor",
                                        GDBUS_ARGS({ "application", "o" }),
                                        NULL, register_monitor) },
        { GDBUS_EXPERIMENTAL_ASYNC_METHOD("UnregisterMonitor",