exit main loop correctly

This commit is contained in:
Dmitriy Ryajov 2019-09-11 23:45:43 -06:00
parent 8920cd7d60
commit 80267e81ec
1 changed files with 1 additions and 2 deletions

View File

@ -111,7 +111,6 @@ proc list*(m: MultisteamSelect,
proc handle*(m: MultisteamSelect, conn: Connection) {.async, gcsafe.} = proc handle*(m: MultisteamSelect, conn: Connection) {.async, gcsafe.} =
debug "handle: starting multistream handling" debug "handle: starting multistream handling"
while not conn.closed: while not conn.closed:
block main:
var ms = cast[string](await conn.readLp()) var ms = cast[string](await conn.readLp())
ms.removeSuffix("\n") ms.removeSuffix("\n")
@ -141,7 +140,7 @@ proc handle*(m: MultisteamSelect, conn: Connection) {.async, gcsafe.} =
await conn.writeLp((h.proto & "\n")) await conn.writeLp((h.proto & "\n"))
try: try:
await h.protocol.handler(conn, ms) await h.protocol.handler(conn, ms)
break main return
except Exception as exc: except Exception as exc:
debug "handle: exception while handling ", msg = exc.msg debug "handle: exception while handling ", msg = exc.msg
debug "handle: no handlers for ", protocol = ms debug "handle: no handlers for ", protocol = ms