summaryrefslogtreecommitdiff
path: root/profiles/input
diff options
context:
space:
mode:
authorArchie Pusaka <apusaka@chromium.org>2022-05-18 12:33:07 +0800
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-05-18 15:19:43 -0700
commitc159d790e8786581cfa5e5a9e7bd71458a343e44 (patch)
tree6d215a7310a8dcff698d8caa432b3aaac68f7cd8 /profiles/input
parentc7955b2099dc6be46e977229d852612c4817f78f (diff)
downloadbluez-c159d790e8786581cfa5e5a9e7bd71458a343e44.tar.gz
input/device: Notify failure if ctrl disconnect when waiting intr
On some rare occasions, the peer HID device might disconnect the ctrl channel when we are trying to connect the intr channel. If this happens, interrupt_connect_cb() will not be called by btio, and we will be stuck in "connecting" state. Any future connection attempt to the peer device will fail because of "busy". This patch prevents that by checking if we need to report connection failure when the ctrl channel is disconnected. Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Diffstat (limited to 'profiles/input')
-rw-r--r--profiles/input/device.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/profiles/input/device.c b/profiles/input/device.c
index ff4aa771a..e2ac6ea60 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -581,6 +581,13 @@ static gboolean ctrl_watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data
if (idev->intr_io && !(cond & G_IO_NVAL))
g_io_channel_shutdown(idev->intr_io, TRUE, NULL);
+ /* It's possible this is triggered while the intr channel is not even
+ * connected yet, therefore we are still in the connecting state.
+ */
+ if (btd_service_get_state(idev->service) ==
+ BTD_SERVICE_STATE_CONNECTING)
+ btd_service_connecting_complete(idev->service, -EIO);
+
if (!idev->intr_io && idev->virtual_cable_unplug)
virtual_cable_unplug(idev);