always close sockets

This commit is contained in:
Christian Ulrich 2020-10-06 23:27:48 +02:00
parent b5406aa83b
commit 1f16800b73
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 2 additions and 2 deletions

View File

@ -186,7 +186,7 @@ proc doConnect(srcIp: IpAddress, srcPort: Port, dstIp: IpAddress, dstPort: Port,
future.complete(sock) future.complete(sock)
except OSError as e: except OSError as e:
echo &"connection {srcIP}:{srcPort.int} -> {dstIp}:{dstPort.int} failed: ", e.msg echo &"connection {srcIP}:{srcPort.int} -> {dstIp}:{dstPort.int} failed: ", e.msg
discard sock.close()
proc connect*(puncher: TcpSyniPuncher, srcPort: Port, dstIp: IpAddress, proc connect*(puncher: TcpSyniPuncher, srcPort: Port, dstIp: IpAddress,
dstPorts: seq[Port], dstPorts: seq[Port],
@ -230,7 +230,7 @@ proc prepareAccept(attempt: AcceptAttempt) {.async.} =
await connectFuture or sleepAsync(Timeout) await connectFuture or sleepAsync(Timeout)
if connectFuture.finished(): if connectFuture.finished():
echo "connected during accept phase" echo "connected during accept phase"
sock.close() sock.close()
except OSError: except OSError:
discard discard