Skip to content

Commit bed926c

Browse files
committed
Avoid double connecting to remote_addr for datagram transports
Issue #276.
1 parent dd4cb7a commit bed926c

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

tests/test_udp.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,30 @@ def connection_lost(self, exc):
226226

227227
self.assertIn(tmp_file2, pr.addrs)
228228

229+
def test_create_datagram_1(self):
230+
server_addr = ('127.0.0.1', 8888)
231+
client_addr = ('127.0.0.1', 0)
232+
233+
async def run():
234+
server_transport, client_protocol = \
235+
await self.loop.create_datagram_endpoint(
236+
asyncio.DatagramProtocol,
237+
local_addr=server_addr)
238+
239+
client_transport, client_conn = \
240+
await self.loop.create_datagram_endpoint(
241+
asyncio.DatagramProtocol,
242+
remote_addr=server_addr,
243+
local_addr=client_addr)
244+
245+
client_transport.close()
246+
server_transport.close()
247+
248+
# let transports close
249+
await asyncio.sleep(0.1)
250+
251+
self.loop.run_until_complete(run())
252+
229253

230254
class Test_UV_UDP(_TestUDP, tb.UVTestCase):
231255

uvloop/loop.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,8 +3040,6 @@ cdef class Loop:
30403040
'could not bind to remote_addr {}'.format(
30413041
remote_addr))
30423042

3043-
udp._connect(rai.ai_addr, rai.ai_addrlen)
3044-
30453043
if allow_broadcast:
30463044
udp._set_broadcast(1)
30473045

0 commit comments

Comments
 (0)