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.} =
|
method close*(s: ChronosStream) {.async, gcsafe.} =
|
||||||
if not s.closed:
|
if not s.closed:
|
||||||
trace "closing connection for", address = $s.client.remoteAddress()
|
trace "shutting down server", address = $s.client.remoteAddress()
|
||||||
if not s.reader.closed:
|
|
||||||
await s.reader.closeWait()
|
|
||||||
|
|
||||||
await s.writer.finish()
|
await s.writer.finish()
|
||||||
if not s.writer.closed:
|
|
||||||
await s.writer.closeWait()
|
await s.writer.closeWait()
|
||||||
|
await s.reader.closeWait()
|
||||||
if not s.client.closed:
|
|
||||||
await s.client.closeWait()
|
await s.client.closeWait()
|
||||||
|
|
||||||
s.closed = true
|
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
|
# always get the resolved address in case we're bound to 0.0.0.0:0
|
||||||
t.ma = t.server.sock.getLocalAddress().toMultiAddr()
|
t.ma = t.server.sock.getLocalAddress().toMultiAddr()
|
||||||
result = t.server.join()
|
result = t.server.join()
|
||||||
|
trace "started node on", address = t.ma
|
||||||
|
|
||||||
method dial*(t: TcpTransport,
|
method dial*(t: TcpTransport,
|
||||||
address: MultiAddress):
|
address: MultiAddress):
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
## those terms.
|
## those terms.
|
||||||
|
|
||||||
import sequtils
|
import sequtils
|
||||||
import chronos
|
import chronos, chronicles
|
||||||
import ../peerinfo,
|
import ../peerinfo,
|
||||||
../connection,
|
../connection,
|
||||||
../multiaddress,
|
../multiaddress,
|
||||||
|
@ -47,6 +47,7 @@ method listen*(t: Transport,
|
||||||
## listen for incoming connections
|
## listen for incoming connections
|
||||||
t.ma = ma
|
t.ma = ma
|
||||||
t.handler = handler
|
t.handler = handler
|
||||||
|
debug "starting node", address = $ma
|
||||||
|
|
||||||
method dial*(t: Transport,
|
method dial*(t: Transport,
|
||||||
address: MultiAddress):
|
address: MultiAddress):
|
||||||
|
|
Loading…
Reference in New Issue