RFCOMM socket : free connection info before sending callback
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-rfcomm-client.c
index ec57e1e..58cf81f 100644 (file)
@@ -269,15 +269,14 @@ static void _bt_rfcomm_disconnect_conn_info(rfcomm_conn_info_t *conn_info,
        BT_DBG("Disconnection Result[%d] BT_ADDRESS[%s] UUID[%s] FD[%d]",
                        BLUETOOTH_ERROR_NONE, conn_info->bt_addr,
                        info->uuid, conn_info->fd);
-       _bt_common_event_cb(BLUETOOTH_EVENT_RFCOMM_DISCONNECTED,
-                       BLUETOOTH_ERROR_NONE, &disconn_info,
-                       event_info->cb, event_info->user_data);
-
        __rfcomm_remove_conn_info_t(info, conn_info->bt_addr);
-
        if (info->rfcomm_conns == NULL)
                rfcomm_cb_data_remove(info);
 
+       _bt_common_event_cb(BLUETOOTH_EVENT_RFCOMM_DISCONNECTED,
+                       BLUETOOTH_ERROR_NONE, &disconn_info,
+                       event_info->cb, event_info->user_data);
+
        BT_DBG("-");
 }
 
@@ -451,9 +450,8 @@ void _bt_rfcomm_client_disconnect_all(void)
                        close(conn_info->fd);
                        conn_info->disconnected = TRUE;
 
-                       _bt_disconnect_profile(conn_info->bt_addr, info->uuid,
-                                       NULL, NULL);
-
+                       _bt_disconnect_ext_profile(conn_info->bt_addr,
+                                                  info->obj_path);
                }
 
                client = client->next;
@@ -692,6 +690,7 @@ BT_EXPORT_API int bluetooth_rfcomm_connect(
                object_id = _bt_register_new_conn(path, new_connection);
                if (object_id < 0) {
                        __rfcomm_delete_id(id);
+                       g_free(path);
                        return BLUETOOTH_ERROR_INTERNAL;
                }
 
@@ -873,7 +872,7 @@ BT_EXPORT_API int bluetooth_rfcomm_disconnect(int socket_fd)
        conn_info->disconnected = TRUE;
 
        BT_INFO("conn_info %s", conn_info->bt_addr);
-       _bt_disconnect_profile(conn_info->bt_addr, info->uuid, NULL, NULL);
+       _bt_disconnect_ext_profile(conn_info->bt_addr, info->obj_path);
 
        if (info->idle_id == 0)
                info->idle_id = g_idle_add(__rfcomm_client_disconnect, info);