fix segfault

This commit is contained in:
Christian Ulrich 2020-11-17 22:39:33 +01:00
parent 6edf6b7e23
commit 5b79592a62
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 3 additions and 3 deletions

View File

@ -62,7 +62,9 @@ proc getEndpoint(srcPort: Port, serverHostname: string, serverPort: Port):
proc initServerConnection*(serverHostname: string, serverPort: Port,
srcPort: Port, probingServers: seq[Endpoint]):
Future[ServerConnection] {.async.} =
result.srcPort = srcPort
result = ServerConnection(outMessages: newTable[string, Future[string]](),
peerNotifications: newFutureStream[string]("initServerConnection"),
srcPort: srcPort)
for s in probingServers:
let endpoint = await getEndpoint(srcPort, s.hostname, s.port)
# FIXME: what if we get get different IPs from different servers
@ -70,8 +72,6 @@ proc initServerConnection*(serverHostname: string, serverPort: Port,
result.probedSrcPorts.add(endpoint.port)
result.sock = await asyncnet.dial(serverHostname,
serverPort)
result.outMessages = newTable[string, Future[string]]()
result.peerNotifications = newFutureStream[string]("initServerConnection")
proc handleServerMessages*(conn: ServerConnection) {.async.} =
while true: