mirror of
https://github.com/vacp2p/nim-libp2p.git
synced 2026-01-10 00:07:56 -05:00
fix: force close of streams instead of reset when closing connection (#1466)
This commit is contained in:
@@ -512,7 +512,14 @@ method close*(m: Yamux) {.async: (raises: []).} =
|
||||
trace "Closing yamux"
|
||||
let channels = toSeq(m.channels.values())
|
||||
for channel in channels:
|
||||
await channel.reset(isLocal = true)
|
||||
for (d, s, fut) in channel.sendQueue:
|
||||
fut.fail(newLPStreamEOFError())
|
||||
channel.sendQueue = @[]
|
||||
channel.sendWindow = 0
|
||||
channel.closedLocally = true
|
||||
channel.opened = false
|
||||
await channel.remoteClosed()
|
||||
channel.receivedData.fire()
|
||||
try:
|
||||
await m.connection.write(YamuxHeader.goAway(NormalTermination))
|
||||
except CancelledError as exc:
|
||||
|
||||
@@ -63,7 +63,6 @@ suite "Perf protocol":
|
||||
checkTrackers()
|
||||
|
||||
asyncTest "tcp::yamux":
|
||||
return # nim-libp2p#1462 test fails with stream closed error
|
||||
let server = createSwitch(isServer = true, useYamux = true)
|
||||
let client = createSwitch(useYamux = true)
|
||||
await runTest(server, client)
|
||||
|
||||
Reference in New Issue
Block a user