Cancel l2cap connection result future on abort

This cancels the `connection_result` future of LeCreditBasedChannel when
abort() is called, e.g. if the LE connection disconnects. This makes it
possible for code waiting for a connection to open to detect that the
connection has failed.

Fixes google/bumble#825
This commit is contained in:
Sigurd Ljødal
2025-11-14 14:50:24 +01:00
parent 42711d3d31
commit 7292c2785e

View File

@@ -1149,6 +1149,9 @@ class LeCreditBasedChannel(utils.EventEmitter):
def abort(self) -> None:
if self.state == self.State.CONNECTED:
self._change_state(self.State.DISCONNECTED)
if self.state == self.State.CONNECTING:
if self.connection_result is not None:
self.connection_result.cancel()
def on_pdu(self, pdu: bytes) -> None:
if self.sink is None: