Fix in case of double connections with sctp

This commit is contained in:
Ludovic Chenut 2023-08-18 13:37:08 +02:00
parent 237d723374
commit f8909ff73c
No known key found for this signature in database
GPG Key ID: D9A59B1907F1D50C
1 changed files with 3 additions and 1 deletions

View File

@ -191,7 +191,7 @@ proc getOrCreateConnection(self: Sctp,
self.sentAddress = address
let connErr = self.usrsctpAwait:
conn.sctpSocket.usrsctp_connect(cast[ptr SockAddr](addr sconn), SockLen(sizeof(sconn)))
doAssert 0 == connErr or errno == EINPROGRESS, ($errno) # TODO raise
doAssert 0 == connErr or errno == posix.EINPROGRESS, ($errno) # TODO raise
self.connections[address] = conn
return conn
@ -308,6 +308,8 @@ proc connect*(self: Sctp,
sctpPort: uint16 = 5000): Future[SctpConnection] {.async.} =
trace "Connect", address
let conn = await self.getOrCreateConnection(self.udp, address, sctpPort)
if conn.state == Connected:
return conn
try:
await conn.connectEvent.wait()
except CancelledError as exc: