mirror of
https://github.com/vacp2p/nim-libp2p-experimental.git
synced 2025-01-12 19:34:23 +00:00
Avoid closing connection on channel EOF (#816)
This commit is contained in:
parent
9f658c151e
commit
ba451196e8
@ -244,7 +244,11 @@ proc completeWrite(
|
|||||||
except CancelledError as exc:
|
except CancelledError as exc:
|
||||||
# Chronos may still send the data
|
# Chronos may still send the data
|
||||||
raise exc
|
raise exc
|
||||||
except LPStreamClosedError as exc:
|
except LPStreamConnDownError as exc:
|
||||||
|
await s.reset()
|
||||||
|
await s.conn.close()
|
||||||
|
raise exc
|
||||||
|
except LPStreamEOFError as exc:
|
||||||
raise exc
|
raise exc
|
||||||
except CatchableError as exc:
|
except CatchableError as exc:
|
||||||
trace "exception in lpchannel write handler", s, msg = exc.msg
|
trace "exception in lpchannel write handler", s, msg = exc.msg
|
||||||
|
@ -177,8 +177,14 @@ method handle*(m: Mplex) {.async, gcsafe.} =
|
|||||||
raise newLPStreamLimitError()
|
raise newLPStreamLimitError()
|
||||||
|
|
||||||
trace "pushing data to channel", m, channel, len = data.len
|
trace "pushing data to channel", m, channel, len = data.len
|
||||||
await channel.pushData(data)
|
try:
|
||||||
trace "pushed data to channel", m, channel, len = data.len
|
await channel.pushData(data)
|
||||||
|
trace "pushed data to channel", m, channel, len = data.len
|
||||||
|
except LPStreamClosedError as exc:
|
||||||
|
# Channel is being closed, but `cleanupChann` was not yet triggered.
|
||||||
|
trace "pushing data to channel failed", m, channel, len = data.len,
|
||||||
|
msg = exc.msg
|
||||||
|
discard # Ignore message, same as if `cleanupChann` had completed.
|
||||||
|
|
||||||
of MessageType.CloseIn, MessageType.CloseOut:
|
of MessageType.CloseIn, MessageType.CloseOut:
|
||||||
await channel.pushEof()
|
await channel.pushEof()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user