adapter: Check whether adapter is pending powered
authorArchie Pusaka <apusaka@chromium.org>
Mon, 22 Feb 2021 05:18:45 +0000 (13:18 +0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:34 +0000 (19:08 +0530)
commit8d44a5789e6856ffbd959a1418a0d86a8d95ffc0
tree831365e576e4bf580ef5dd00b3f682ef52e8b450
parent5370156e35f7c82f643a62384e7a211d0ec1646e
adapter: Check whether adapter is pending powered

The powered setting of adapter is frequently being checked, but the
check only accounts for whether it currently is powered. When powering
off the adapter, there is a brief moment when the adapter is already
off kernel-wise, but powered property is still true.

If powered property is accessed at this time, some problems might
occur. For example, if RemoveDevice DBus API is called, we would still
carry out the request and remove the device from the user space, but
we would fail to remove it from the kernel, therefore resulting an
error when we want to re-pair the device.

This patch addresses this issue by also checking whether adapter is
being powered off when checking for powered.

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/adapter.c