mirror of https://github.com/vacp2p/nim-libp2p.git
prperly close and chronos connections
This commit is contained in:
parent
968fd85d49
commit
a01d1db6a0
|
@ -95,15 +95,10 @@ method write*(s: ChronosStream, msg: seq[byte], msglen = -1) {.async, gcsafe.} =
|
|||
|
||||
method close*(s: ChronosStream) {.async, gcsafe.} =
|
||||
if not s.closed:
|
||||
trace "closing connection for", address = $s.client.remoteAddress()
|
||||
if not s.reader.closed:
|
||||
await s.reader.closeWait()
|
||||
|
||||
trace "shutting down server", address = $s.client.remoteAddress()
|
||||
await s.writer.finish()
|
||||
if not s.writer.closed:
|
||||
await s.writer.closeWait()
|
||||
await s.writer.closeWait()
|
||||
await s.reader.closeWait()
|
||||
await s.client.closeWait()
|
||||
|
||||
if not s.client.closed:
|
||||
await s.client.closeWait()
|
||||
|
||||
s.closed = true
|
||||
|
|
|
@ -67,6 +67,7 @@ method listen*(t: TcpTransport,
|
|||
# always get the resolved address in case we're bound to 0.0.0.0:0
|
||||
t.ma = t.server.sock.getLocalAddress().toMultiAddr()
|
||||
result = t.server.join()
|
||||
trace "started node on", address = t.ma
|
||||
|
||||
method dial*(t: TcpTransport,
|
||||
address: MultiAddress):
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
## those terms.
|
||||
|
||||
import sequtils
|
||||
import chronos
|
||||
import chronos, chronicles
|
||||
import ../peerinfo,
|
||||
../connection,
|
||||
../multiaddress,
|
||||
|
@ -47,6 +47,7 @@ method listen*(t: Transport,
|
|||
## listen for incoming connections
|
||||
t.ma = ma
|
||||
t.handler = handler
|
||||
debug "starting node", address = $ma
|
||||
|
||||
method dial*(t: Transport,
|
||||
address: MultiAddress):
|
||||
|
|
Loading…
Reference in New Issue