device: remove "feature" which enable accept to return the same connection has connect

This commit is contained in:
uael
2023-02-10 20:10:59 +00:00
parent 1321c7da81
commit ad27de7717
2 changed files with 2 additions and 15 deletions

View File

@@ -1827,7 +1827,7 @@ class Device(CompositeEventEmitter):
set. set.
Notes: Notes:
* A `connect` to the same peer will also complete this call. * A `connect` to the same peer will not complete this call.
* The `timeout` parameter is only handled while waiting for the connection * The `timeout` parameter is only handled while waiting for the connection
request, once received and accepted, the controller shall issue a connection request, once received and accepted, the controller shall issue a connection
complete event. complete event.
@@ -2409,16 +2409,6 @@ class Device(CompositeEventEmitter):
) )
self.connections[connection_handle] = connection self.connections[connection_handle] = connection
# We may have an accept ongoing waiting for a connection request for
# `peer_address`.
# Typically happen when using `connect` to the same `peer_address` we are
# waiting for with an `accept`.
# In this case, set the completed `connection` to the `accept` future
# result.
if peer_address in self.classic_pending_accepts:
future, *_ = self.classic_pending_accepts.pop(peer_address)
future.set_result(connection)
# Emit an event to notify listeners of the new connection # Emit an event to notify listeners of the new connection
self.emit('connection', connection) self.emit('connection', connection)
else: else:

View File

@@ -197,7 +197,7 @@ async def test_device_connect_parallel():
d1.host.set_packet_sink(Sink(d1_flow())) d1.host.set_packet_sink(Sink(d1_flow()))
d2.host.set_packet_sink(Sink(d2_flow())) d2.host.set_packet_sink(Sink(d2_flow()))
[c01, c02, a10, a20, a01] = await asyncio.gather( [c01, c02, a10, a20] = await asyncio.gather(
*[ *[
asyncio.create_task( asyncio.create_task(
d0.connect(d1.public_address, transport=BT_BR_EDR_TRANSPORT) d0.connect(d1.public_address, transport=BT_BR_EDR_TRANSPORT)
@@ -207,7 +207,6 @@ async def test_device_connect_parallel():
), ),
asyncio.create_task(d1.accept(peer_address=d0.public_address)), asyncio.create_task(d1.accept(peer_address=d0.public_address)),
asyncio.create_task(d2.accept()), asyncio.create_task(d2.accept()),
asyncio.create_task(d0.accept(peer_address=d1.public_address)),
] ]
) )
@@ -215,11 +214,9 @@ async def test_device_connect_parallel():
assert type(c02) == Connection assert type(c02) == Connection
assert type(a10) == Connection assert type(a10) == Connection
assert type(a20) == Connection assert type(a20) == Connection
assert type(a01) == Connection
assert c01.handle == a10.handle and c01.handle == 0x100 assert c01.handle == a10.handle and c01.handle == 0x100
assert c02.handle == a20.handle and c02.handle == 0x101 assert c02.handle == a20.handle and c02.handle == 0x101
assert a01 == c01
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------