device: Fix race condition between device connection and disconnection
authorSonny Sasaka <sonnysasaka@chromium.org>
Fri, 21 Aug 2020 18:01:06 +0000 (11:01 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 12 Apr 2021 09:00:50 +0000 (14:30 +0530)
commit51ec25851a8668605377dfcb1453104d37dacd29
tree236a3e438cb63805c281e9ba2edb15993d73e583
parent79dfd19d25a572314807949361adcb2fc203224d
device: Fix race condition between device connection and disconnection

When Connect() is called and waiting for return, dev_disconnected may be
called due to MGMT_EV_DEVICE_DISCONNECTED event from kernel. In that
case reply to client that the connection failed otherwise the dbus
method will timeout because bluetoothd never replies.

Tested with simulation of a lot of Connect() to bluetooth devices and
check that error is returned from bluetoothd rather than dbus timeout
when this race condition happens.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/device.c