This commit is contained in:
Dmitriy Ryajov 2020-05-12 05:18:20 -06:00
parent 0f691cbafd
commit 46daed9a38
2 changed files with 5 additions and 3 deletions

View File

@ -77,7 +77,6 @@ proc newChannel*(id: uint64,
result.msgCode = if initiator: MessageType.MsgOut else: MessageType.MsgIn
result.closeCode = if initiator: MessageType.CloseOut else: MessageType.CloseIn
result.resetCode = if initiator: MessageType.ResetOut else: MessageType.ResetIn
result.writeLock = newAsyncLock()
result.isLazy = lazy
let chan = result
@ -178,6 +177,7 @@ method close*(s: LPChannel) {.async, gcsafe.} =
s.closedLocal = true
if s.atEof: # already closed by remote close parent buffer imediately
await procCall BufferStream(s).close()
trace "lpchannel closed local", id = s.id,
initiator = s.initiator,
name = s.name,

View File

@ -276,11 +276,12 @@ suite "Mplex":
let mplexDial = newMplex(conn)
let stream = await mplexDial.newStream(lazy = true)
let mplexDialFut = mplexDial.handle()
check not LPChannel(stream.stream).isOpen # assert lazy
let openState = cast[LPChannel](stream).isOpen
await stream.writeLp("HELLO")
check LPChannel(stream.stream).isOpen # assert lazy
await stream.close()
check not openState # assert lazy
await done.wait(1.seconds)
await conn.close()
await mplexDialFut
@ -387,6 +388,7 @@ suite "Mplex":
check string.fromBytes(msg) == &"stream {count}!"
count.inc
await stream.close()
count.inc
if count == 10:
done.complete()