close connections

This commit is contained in:
Dmitriy Ryajov 2020-04-04 20:43:23 -06:00
parent bae4713a85
commit 87b35de83e
2 changed files with 6 additions and 4 deletions

View File

@ -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.} =

View File

@ -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)