wip
This commit is contained in:
parent
0f691cbafd
commit
46daed9a38
|
@ -77,7 +77,6 @@ proc newChannel*(id: uint64,
|
||||||
result.msgCode = if initiator: MessageType.MsgOut else: MessageType.MsgIn
|
result.msgCode = if initiator: MessageType.MsgOut else: MessageType.MsgIn
|
||||||
result.closeCode = if initiator: MessageType.CloseOut else: MessageType.CloseIn
|
result.closeCode = if initiator: MessageType.CloseOut else: MessageType.CloseIn
|
||||||
result.resetCode = if initiator: MessageType.ResetOut else: MessageType.ResetIn
|
result.resetCode = if initiator: MessageType.ResetOut else: MessageType.ResetIn
|
||||||
result.writeLock = newAsyncLock()
|
|
||||||
result.isLazy = lazy
|
result.isLazy = lazy
|
||||||
|
|
||||||
let chan = result
|
let chan = result
|
||||||
|
@ -178,6 +177,7 @@ method close*(s: LPChannel) {.async, gcsafe.} =
|
||||||
s.closedLocal = true
|
s.closedLocal = true
|
||||||
if s.atEof: # already closed by remote close parent buffer imediately
|
if s.atEof: # already closed by remote close parent buffer imediately
|
||||||
await procCall BufferStream(s).close()
|
await procCall BufferStream(s).close()
|
||||||
|
|
||||||
trace "lpchannel closed local", id = s.id,
|
trace "lpchannel closed local", id = s.id,
|
||||||
initiator = s.initiator,
|
initiator = s.initiator,
|
||||||
name = s.name,
|
name = s.name,
|
||||||
|
|
|
@ -276,11 +276,12 @@ suite "Mplex":
|
||||||
let mplexDial = newMplex(conn)
|
let mplexDial = newMplex(conn)
|
||||||
let stream = await mplexDial.newStream(lazy = true)
|
let stream = await mplexDial.newStream(lazy = true)
|
||||||
let mplexDialFut = mplexDial.handle()
|
let mplexDialFut = mplexDial.handle()
|
||||||
check not LPChannel(stream.stream).isOpen # assert lazy
|
let openState = cast[LPChannel](stream).isOpen
|
||||||
await stream.writeLp("HELLO")
|
await stream.writeLp("HELLO")
|
||||||
check LPChannel(stream.stream).isOpen # assert lazy
|
|
||||||
await stream.close()
|
await stream.close()
|
||||||
|
|
||||||
|
check not openState # assert lazy
|
||||||
|
|
||||||
await done.wait(1.seconds)
|
await done.wait(1.seconds)
|
||||||
await conn.close()
|
await conn.close()
|
||||||
await mplexDialFut
|
await mplexDialFut
|
||||||
|
@ -387,6 +388,7 @@ suite "Mplex":
|
||||||
check string.fromBytes(msg) == &"stream {count}!"
|
check string.fromBytes(msg) == &"stream {count}!"
|
||||||
count.inc
|
count.inc
|
||||||
await stream.close()
|
await stream.close()
|
||||||
|
count.inc
|
||||||
if count == 10:
|
if count == 10:
|
||||||
done.complete()
|
done.complete()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue