mirror of
https://github.com/status-im/nim-chronos.git
synced 2025-01-22 01:10:12 +00:00
Fix datagram problems.
This commit is contained in:
parent
0ea8e65b2c
commit
8a68c66caa
@ -408,7 +408,7 @@ else:
|
|||||||
closeSocket(localSock)
|
closeSocket(localSock)
|
||||||
raiseTransportOsError(err)
|
raiseTransportOsError(err)
|
||||||
|
|
||||||
if local.family != AddressFamily.None:
|
if local.port != Port(0):
|
||||||
var saddr: Sockaddr_storage
|
var saddr: Sockaddr_storage
|
||||||
var slen: SockLen
|
var slen: SockLen
|
||||||
toSAddr(local, saddr, slen)
|
toSAddr(local, saddr, slen)
|
||||||
@ -420,7 +420,7 @@ else:
|
|||||||
raiseTransportOsError(err)
|
raiseTransportOsError(err)
|
||||||
result.local = local
|
result.local = local
|
||||||
|
|
||||||
if remote.family != AddressFamily.None:
|
if remote.port != Port(0):
|
||||||
var saddr: Sockaddr_storage
|
var saddr: Sockaddr_storage
|
||||||
var slen: SockLen
|
var slen: SockLen
|
||||||
toSAddr(remote, saddr, slen)
|
toSAddr(remote, saddr, slen)
|
||||||
|
@ -326,7 +326,6 @@ proc testPointerSendTo(): Future[int] {.async.} =
|
|||||||
await dgram2.sendTo(ta, addr data[0], len(data))
|
await dgram2.sendTo(ta, addr data[0], len(data))
|
||||||
await dgram2.join()
|
await dgram2.join()
|
||||||
dgram1.close()
|
dgram1.close()
|
||||||
dgram2.close()
|
|
||||||
result = counter
|
result = counter
|
||||||
|
|
||||||
proc testPointerSend(): Future[int] {.async.} =
|
proc testPointerSend(): Future[int] {.async.} =
|
||||||
@ -339,7 +338,6 @@ proc testPointerSend(): Future[int] {.async.} =
|
|||||||
await dgram2.send(addr data[0], len(data))
|
await dgram2.send(addr data[0], len(data))
|
||||||
await dgram2.join()
|
await dgram2.join()
|
||||||
dgram1.close()
|
dgram1.close()
|
||||||
dgram2.close()
|
|
||||||
result = counter
|
result = counter
|
||||||
|
|
||||||
proc testStringSendTo(): Future[int] {.async.} =
|
proc testStringSendTo(): Future[int] {.async.} =
|
||||||
@ -352,7 +350,6 @@ proc testStringSendTo(): Future[int] {.async.} =
|
|||||||
await dgram2.sendTo(ta, data)
|
await dgram2.sendTo(ta, data)
|
||||||
await dgram2.join()
|
await dgram2.join()
|
||||||
dgram1.close()
|
dgram1.close()
|
||||||
dgram2.close()
|
|
||||||
result = counter
|
result = counter
|
||||||
|
|
||||||
proc testStringSend(): Future[int] {.async.} =
|
proc testStringSend(): Future[int] {.async.} =
|
||||||
@ -365,7 +362,6 @@ proc testStringSend(): Future[int] {.async.} =
|
|||||||
await dgram2.send(data)
|
await dgram2.send(data)
|
||||||
await dgram2.join()
|
await dgram2.join()
|
||||||
dgram1.close()
|
dgram1.close()
|
||||||
dgram2.close()
|
|
||||||
result = counter
|
result = counter
|
||||||
|
|
||||||
proc testSeqSendTo(): Future[int] {.async.} =
|
proc testSeqSendTo(): Future[int] {.async.} =
|
||||||
@ -380,7 +376,6 @@ proc testSeqSendTo(): Future[int] {.async.} =
|
|||||||
await dgram2.sendTo(ta, dataseq)
|
await dgram2.sendTo(ta, dataseq)
|
||||||
await dgram2.join()
|
await dgram2.join()
|
||||||
dgram1.close()
|
dgram1.close()
|
||||||
dgram2.close()
|
|
||||||
result = counter
|
result = counter
|
||||||
|
|
||||||
proc testSeqSend(): Future[int] {.async.} =
|
proc testSeqSend(): Future[int] {.async.} =
|
||||||
@ -395,7 +390,6 @@ proc testSeqSend(): Future[int] {.async.} =
|
|||||||
await dgram2.send(data)
|
await dgram2.send(data)
|
||||||
await dgram2.join()
|
await dgram2.join()
|
||||||
dgram1.close()
|
dgram1.close()
|
||||||
dgram2.close()
|
|
||||||
result = counter
|
result = counter
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -435,6 +429,7 @@ proc test3(bounded: bool): Future[int] {.async.} =
|
|||||||
|
|
||||||
await waitAll(clients)
|
await waitAll(clients)
|
||||||
dgram1.close()
|
dgram1.close()
|
||||||
|
await dgram1.join()
|
||||||
result = 0
|
result = 0
|
||||||
for i in 0..<ClientsCount:
|
for i in 0..<ClientsCount:
|
||||||
result += counters[i]
|
result += counters[i]
|
||||||
@ -448,6 +443,7 @@ proc testConnReset(): Future[bool] {.async.} =
|
|||||||
transp.close()
|
transp.close()
|
||||||
var dgram1 = newDatagramTransport(client1, local = ta)
|
var dgram1 = newDatagramTransport(client1, local = ta)
|
||||||
dgram1.close()
|
dgram1.close()
|
||||||
|
await dgram1.join()
|
||||||
var dgram2 = newDatagramTransport(clientMark)
|
var dgram2 = newDatagramTransport(clientMark)
|
||||||
var data = "MESSAGE"
|
var data = "MESSAGE"
|
||||||
asyncCheck dgram2.sendTo(ta, data)
|
asyncCheck dgram2.sendTo(ta, data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user