properly exit readLoop on error/stream end
This commit is contained in:
parent
34d1a641de
commit
968fd85d49
|
@ -402,8 +402,14 @@ proc handshake*(s: Secio, conn: Connection): Future[SecureConnection] {.async.}
|
|||
|
||||
proc readLoop(sconn: SecureConnection, stream: BufferStream) {.async.} =
|
||||
while not sconn.conn.closed:
|
||||
try:
|
||||
let msg = await sconn.readMessage()
|
||||
await stream.pushTo(msg)
|
||||
except:
|
||||
trace "exception in secio", exc = getCurrentExceptionMsg()
|
||||
return
|
||||
finally:
|
||||
trace "ending secio readLoop"
|
||||
|
||||
proc handleConn(s: Secio, conn: Connection): Future[Connection] {.async.} =
|
||||
var sconn = await s.handshake(conn)
|
||||
|
@ -419,9 +425,9 @@ proc handleConn(s: Secio, conn: Connection): Future[Connection] {.async.} =
|
|||
|
||||
method init(s: Secio) {.gcsafe.} =
|
||||
proc handle(conn: Connection, proto: string) {.async, gcsafe.} =
|
||||
debug "handling connection"
|
||||
trace "handling connection"
|
||||
discard await s.handleConn(conn)
|
||||
debug "connection secured"
|
||||
trace "connection secured"
|
||||
|
||||
s.codec = SecioCodec
|
||||
s.handler = handle
|
||||
|
|
Loading…
Reference in New Issue