device: Fix not setting initiator
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 24 Aug 2022 21:23:25 +0000 (14:23 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
This fixes not setting initiator flag properly when MGMT connect event
has not been processed yet but ATT is already connected or is in
progress.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/device.c

index ae18ff0..8588714 100644 (file)
@@ -463,7 +463,7 @@ static bool get_initiator(struct btd_device *dev)
        if (dev->bredr_state.connected)
                return dev->bredr_state.initiator;
 
-       return false;
+       return dev->att_io ? true : false;
 }
 
 static GSList *find_service_with_profile(GSList *list, struct btd_profile *p)
@@ -8436,6 +8436,9 @@ static void att_connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
                goto done;
        }
 
+       /* Update connected state */
+       device->le_state.connected = true;
+
        if (!device_attach_att(device, io))
                goto done;