Fix app crash issue when notification register fails 42/315842/1 accepted/tizen/7.0/unified/20240829.160016
authorWootak Jung <wootak.jung@samsung.com>
Thu, 8 Aug 2024 06:50:55 +0000 (15:50 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Thu, 8 Aug 2024 06:50:55 +0000 (15:50 +0900)
Change-Id: I9ac5e5d10fc63b0db41ad0a7c5e327286ffdb729
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-service/services/bt-request-handler.c

index 886e3d34f5eb9c5b1f6e19924f190de79e69c0cf..1834e78fa16787e89c3425f3f87b71c1c640b9ff 100644 (file)
@@ -3173,33 +3173,30 @@ int __bt_bluez_request(int function_name,
 #endif
 
                if (is_indicate == false) {
-                       result   = _bt_gatt_acquire_notify(&param , &fd, &mtu);
-                       if (BLUETOOTH_ERROR_NONE == result && fd > -1) {
-                               BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
-
-                               GUnixFDList *fd_list = NULL;
-                               GError *error = NULL;
-
-                               g_array_append_vals(*out_param1, &mtu, sizeof(int));
-                               /* Add socket fd to unix_fd_list */
-                               fd_list = g_unix_fd_list_new();
-                               g_unix_fd_list_append(fd_list, fd, &error);
-                               g_assert_no_error(error);
-                               close(fd);
-                               _bt_service_method_return_with_unix_fd_list(
-                               context, *out_param1, result, fd_list);
+                       result = _bt_gatt_acquire_notify(&param, &fd, &mtu);
+                       if (result != BLUETOOTH_ERROR_NONE)
+                               break;
 
-                               g_object_unref(fd_list);
-                       } else
-                               goto normal;
-               } else {
+                       BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
 
-normal:
-                       result = _bt_gatt_watch_characteristic(&param , client_id, is_notify);
+                       GUnixFDList *fd_list = NULL;
+                       GError *error = NULL;
+
+                       g_array_append_vals(*out_param1, &mtu, sizeof(int));
+                       /* Add socket fd to unix_fd_list */
+                       fd_list = g_unix_fd_list_new();
+                       g_unix_fd_list_append(fd_list, fd, &error);
+                       g_assert_no_error(error);
+                       close(fd);
+                       _bt_service_method_return_with_unix_fd_list(context, *out_param1, result, fd_list);
+
+                       g_object_unref(fd_list);
+               } else {
+                       result = _bt_gatt_watch_characteristic(&param, client_id, is_notify);
                        if (BLUETOOTH_ERROR_NONE == result) {
                                /* Save the informations to invocation */
                                _bt_save_invocation_context(context, result, sender, function_name,
-                                        (gpointer)g_memdup2(&param, sizeof(bluetooth_gatt_client_char_prop_info_t)));
+                                                (gpointer)g_memdup2(&param, sizeof(bluetooth_gatt_client_char_prop_info_t)));
                        }
                }
                break;