From 87b35de83e8f5aae1c1beb3b2164c1fbe72c4f60 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Sat, 4 Apr 2020 20:43:23 -0600 Subject: [PATCH] close connections --- libp2p/protocols/secure/secio.nim | 6 +++--- libp2p/protocols/secure/secure.nim | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libp2p/protocols/secure/secio.nim b/libp2p/protocols/secure/secio.nim index 0452fef..95a99ff 100644 --- a/libp2p/protocols/secure/secio.nim +++ b/libp2p/protocols/secure/secio.nim @@ -281,11 +281,11 @@ proc transactMessage(conn: Connection, else: trace "Received size of message exceed limits", conn = $conn, length = length - except AsyncStreamIncompleteError: + except LPStreamIncompleteError: trace "Connection dropped while reading", conn = $conn - except AsyncStreamReadError: + except LPStreamReadError: trace "Error reading from connection", conn = $conn - except AsyncStreamWriteError: + except LPStreamWriteError: trace "Could not write to connection", conn = $conn method handshake*(s: Secio, conn: Connection, initiator: bool = false): Future[SecureConn] {.async.} = diff --git a/libp2p/protocols/secure/secure.nim b/libp2p/protocols/secure/secure.nim index 980e8d0..846f4f7 100644 --- a/libp2p/protocols/secure/secure.nim +++ b/libp2p/protocols/secure/secure.nim @@ -47,12 +47,14 @@ proc readLoop(sconn: SecureConn, conn: Connection) {.async.} = except CatchableError as exc: trace "Exception occurred Secure.readLoop", exc = exc.msg finally: + trace "closing conn", closed = conn.closed() if not conn.closed: await conn.close() + trace "closing sconn", closed = sconn.closed() if not sconn.closed: await sconn.close() - trace "ending Secure readLoop", isclosed = sconn.closed() + trace "ending Secure readLoop" proc handleConn*(s: Secure, conn: Connection, initiator: bool = false): Future[Connection] {.async, gcsafe.} = var sconn = await s.handshake(conn, initiator)