Revert "Implement timeout in mplex in order to read reliably close state"
This reverts commit 314cb6e6bffe122bcfbd155a4ef830849ace66ef.
This commit is contained in:
parent
11bd55308f
commit
39dc9ad8a3
|
@ -23,8 +23,6 @@ import ../muxer,
|
||||||
logScope:
|
logScope:
|
||||||
topic = "Mplex"
|
topic = "Mplex"
|
||||||
|
|
||||||
const HandleTimeout = 30.seconds
|
|
||||||
|
|
||||||
type
|
type
|
||||||
Mplex* = ref object of Muxer
|
Mplex* = ref object of Muxer
|
||||||
remote*: Table[uint, LPChannel]
|
remote*: Table[uint, LPChannel]
|
||||||
|
@ -61,20 +59,15 @@ proc cleanupChann(m: Mplex, chann: LPChannel, initiator: bool) {.async, inline.}
|
||||||
m.getChannelList(initiator).del(chann.id)
|
m.getChannelList(initiator).del(chann.id)
|
||||||
trace "cleaned up channel", id = chann.id
|
trace "cleaned up channel", id = chann.id
|
||||||
|
|
||||||
proc messageTimeout(t: Duration): Future[Option[Msg]] {.async, inline.} =
|
|
||||||
await sleepAsync(t)
|
|
||||||
return Msg.none
|
|
||||||
|
|
||||||
method handle*(m: Mplex) {.async, gcsafe.} =
|
method handle*(m: Mplex) {.async, gcsafe.} =
|
||||||
trace "starting mplex main loop"
|
trace "starting mplex main loop"
|
||||||
try:
|
try:
|
||||||
while not m.connection.closed:
|
while not m.connection.closed:
|
||||||
trace "waiting for data"
|
trace "waiting for data"
|
||||||
let
|
let msg = await m.connection.readMsg()
|
||||||
res = await one(m.connection.readMsg(), messageTimeout(HandleTimeout))
|
|
||||||
msg = res.read()
|
|
||||||
if msg.isNone:
|
if msg.isNone:
|
||||||
trace "connection EOF"
|
trace "connection EOF"
|
||||||
|
# TODO: allow poll with timeout to avoid using `sleepAsync`
|
||||||
await sleepAsync(1.millis)
|
await sleepAsync(1.millis)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue