Fix WriteValue timeout issue 24/309824/1
authorWootak Jung <wootak.jung@samsung.com>
Sun, 7 Apr 2024 23:18:17 +0000 (08:18 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Wed, 17 Apr 2024 03:11:10 +0000 (12:11 +0900)
Apr 04 16:11:51.062065 Samsung-FamilyHub bluetoothd[6483]: src/gatt-database.c:pending_write_new() ### op 0xabccb558 attrib 0xabccd568 queue 0xabccf2e0 id 1
Apr 04 16:11:51.062329 Samsung-FamilyHub bluetoothd[6483]: src/gatt-database.c:send_write() ### op 0xabccb558 attrib 0xabccd568
// timeout occurs if no reply
Apr 04 16:16:51.064207 Samsung-FamilyHub bluetoothd[6483]: src/gatt-database.c:pending_op_free() op 0xabccb558

g_dbus_method_invocation_return_value:
 * if (error != NULL)
 *   g_dbus_method_invocation_return_gerror (invocation, error);
 * else
 *   g_dbus_method_invocation_return_value (invocation,
 *                                          g_variant_new ("(s)", result_string));
 *
 * // Do not free @invocation here; returning a value does that
 * ]|
 *
 * This method will take ownership of @invocation. See
 * #GDBusInterfaceVTable for more information about the ownership of
 * @invocation.

GDBusInterfaceVTable:
Ownership of the GDBusMethodInvocation object passed to the method_call() function
is transferred to your handler; you must call one of the methods of GDBusMethodInvocation
to return a reply (possibly empty), or an error.
These functions also take ownership of the passed-in invocation object,
so unless the invocation object has otherwise been referenced, it will be then be freed.

Change-Id: I389475519d912044bff5d98ceffa8064ec9012d3
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-oal/bluez_hal/src/bt-hal-gatt-server.c

index 290c0d8..fe472f1 100644 (file)
@@ -1204,10 +1204,7 @@ static void __bt_gatt_desc_method_call(GDBusConnection *connection,
 
                if (conn_info == NULL || svc_info == NULL || event_cb == NULL) {
                        g_variant_unref(var);
-                       if (response_needed)
-                               g_dbus_method_invocation_return_value(invocation, NULL);
-                       else
-                               g_object_unref(invocation);
+                       g_dbus_method_invocation_return_value(invocation, NULL);
                        return;
                }
 
@@ -1231,7 +1228,8 @@ static void __bt_gatt_desc_method_call(GDBusConnection *connection,
                        /* Append request info in list of requests for the particular connection */
                        conn_info->gatt_req_info_list = g_slist_append(conn_info->gatt_req_info_list, req_info);
                } else {
-                       g_object_unref(invocation);
+                       /* Send reply now */
+                       g_dbus_method_invocation_return_value(invocation, NULL);
                }
 
                /* Send HAL event */
@@ -1351,10 +1349,7 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
 
                if (svc_info == NULL || conn_info == NULL || event_cb == NULL) {
                        g_variant_unref(var);
-                       if (response_needed)
-                               g_dbus_method_invocation_return_value(invocation, NULL);
-                       else
-                               g_object_unref(invocation);
+                       g_dbus_method_invocation_return_value(invocation, NULL);
                        return;
                }
 
@@ -1380,7 +1375,8 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                        conn_info->gatt_req_info_list = g_slist_append(conn_info->gatt_req_info_list, req_info);
 
                } else {
-                       g_object_unref(invocation);
+                       /* Send reply now */
+                       g_dbus_method_invocation_return_value(invocation, NULL);
                }
 
                /* Send HAL event */