fix(yamux): future leak (#1171)
This commit is contained in:
parent
cde5ed7e8c
commit
55cc5434fe
|
@ -279,10 +279,15 @@ method readOnce*(
|
|||
raise newLPStreamRemoteClosedError()
|
||||
if channel.recvQueue.len == 0:
|
||||
channel.receivedData.clear()
|
||||
try: # https://github.com/status-im/nim-chronos/issues/516
|
||||
discard await race(channel.closedRemotely.wait(), channel.receivedData.wait())
|
||||
except ValueError:
|
||||
raiseAssert("Futures list is not empty")
|
||||
let
|
||||
closedRemotelyFut = channel.closedRemotely.wait()
|
||||
receivedDataFut = channel.receivedData.wait()
|
||||
defer:
|
||||
if not closedRemotelyFut.finished():
|
||||
await closedRemotelyFut.cancelAndWait()
|
||||
if not receivedDataFut.finished():
|
||||
await receivedDataFut.cancelAndWait()
|
||||
await closedRemotelyFut or receivedDataFut
|
||||
if channel.closedRemotely.isSet() and channel.recvQueue.len == 0:
|
||||
channel.isEof = true
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue