Fix WriteValue timeout issue 24/309224/2 accepted/tizen/7.0/unified/20240409.073811 accepted/tizen/7.0/unified/20240409.104413
authorWootak Jung <wootak.jung@samsung.com>
Sun, 7 Apr 2024 23:18:17 +0000 (08:18 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Sun, 7 Apr 2024 23:41:14 +0000 (08:41 +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 6c007c8..e3cef0a 100644 (file)
@@ -1203,10 +1203,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;
                }
 
@@ -1230,7 +1227,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 */
@@ -1350,10 +1348,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;
                }
 
@@ -1379,7 +1374,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 */