don't forget closing the stream when final `{Fin}` fails in yamux (#1043)

This commit is contained in:
Etan Kissling 2024-03-04 00:05:59 +01:00 committed by GitHub
parent d43c5feab0
commit 0b753e7cf2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -199,8 +199,9 @@ method closeImpl*(channel: YamuxChannel) {.async.} =
channel.closedLocally = true
channel.isEof = true
if channel.isReset == false and channel.sendQueue.len == 0:
await channel.conn.write(YamuxHeader.data(channel.id, 0, {Fin}))
if not channel.isReset and channel.sendQueue.len == 0:
try: await channel.conn.write(YamuxHeader.data(channel.id, 0, {Fin}))
except CancelledError, LPStreamError: discard
await channel.actuallyClose()
proc reset(channel: YamuxChannel, isLocal: bool = false) {.async.} =