Skip to content

Commit

Permalink
Fix _wait_removed completion on invalid object path
Browse files Browse the repository at this point in the history
The _wait_removed method registers the "InterfacesRemoved" callback on
the adapter path of the device without checking which object was
removed when called.
This means that any removed interface while a connection is
being established can cause the _wait_removed to complete and cancel
the connection.

This commit simply checks that the callback is for the proper device
object path.

Fixes hbldh#1489
  • Loading branch information
arthur-proglove committed Apr 25, 2024
1 parent 3886f10 commit 6a0fe08
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Fixed
* Fixed BlueZ version in passive scanning error message. Fixes #1433.
* Fixed mypy requiring ``Unpack[ExtraArgs]`` that were intended to be optional. Fixes #1487.
* Fixed ``KeyError`` in BlueZ ``is_connected()`` and ``get_global_bluez_manager()`` when device is not present. Fixes #1507.
* Fixed BlueZ _wait_removed completion on invalid object path. Fixes #1489.

`0.21.1`_ (2023-09-08)
======================
Expand Down
5 changes: 3 additions & 2 deletions bleak/backends/bluezdbus/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,9 @@ async def _wait_removed(self, device_path: str) -> None:

event = asyncio.Event()

def callback(_: str):
event.set()
def callback(o: str) -> None:
if o == device_path:
event.set()

device_removed_callback_and_state = DeviceRemovedCallbackAndState(
callback, self._properties[device_path][defs.DEVICE_INTERFACE]["Adapter"]
Expand Down

0 comments on commit 6a0fe08

Please sign in to comment.