mirror of
https://github.com/vacp2p/nim-libp2p.git
synced 2025-01-26 16:40:51 +00:00
fix(yamux): future leak (#1171)
This commit is contained in:
parent
cde5ed7e8c
commit
55cc5434fe
@ -279,10 +279,15 @@ method readOnce*(
|
|||||||
raise newLPStreamRemoteClosedError()
|
raise newLPStreamRemoteClosedError()
|
||||||
if channel.recvQueue.len == 0:
|
if channel.recvQueue.len == 0:
|
||||||
channel.receivedData.clear()
|
channel.receivedData.clear()
|
||||||
try: # https://github.com/status-im/nim-chronos/issues/516
|
let
|
||||||
discard await race(channel.closedRemotely.wait(), channel.receivedData.wait())
|
closedRemotelyFut = channel.closedRemotely.wait()
|
||||||
except ValueError:
|
receivedDataFut = channel.receivedData.wait()
|
||||||
raiseAssert("Futures list is not empty")
|
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:
|
if channel.closedRemotely.isSet() and channel.recvQueue.len == 0:
|
||||||
channel.isEof = true
|
channel.isEof = true
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user