From 39dc9ad8a30ddd0449306e967d0d76347ee01960 Mon Sep 17 00:00:00 2001 From: Giovanni Petrantoni Date: Wed, 12 Feb 2020 17:29:21 +0900 Subject: [PATCH] Revert "Implement timeout in mplex in order to read reliably close state" This reverts commit 314cb6e6bffe122bcfbd155a4ef830849ace66ef. --- libp2p/muxers/mplex/mplex.nim | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libp2p/muxers/mplex/mplex.nim b/libp2p/muxers/mplex/mplex.nim index 92ebaac8e..4a8769daa 100644 --- a/libp2p/muxers/mplex/mplex.nim +++ b/libp2p/muxers/mplex/mplex.nim @@ -23,8 +23,6 @@ import ../muxer, logScope: topic = "Mplex" -const HandleTimeout = 30.seconds - type Mplex* = ref object of Muxer remote*: Table[uint, LPChannel] @@ -61,20 +59,15 @@ proc cleanupChann(m: Mplex, chann: LPChannel, initiator: bool) {.async, inline.} m.getChannelList(initiator).del(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.} = trace "starting mplex main loop" try: while not m.connection.closed: trace "waiting for data" - let - res = await one(m.connection.readMsg(), messageTimeout(HandleTimeout)) - msg = res.read() + let msg = await m.connection.readMsg() if msg.isNone: trace "connection EOF" + # TODO: allow poll with timeout to avoid using `sleepAsync` await sleepAsync(1.millis) continue