Skip to content

Commit

Permalink
MplexHandler: reading from a stream which was closed remotely for wri…
Browse files Browse the repository at this point in the history
…ting should result in exception
  • Loading branch information
Nashatyrev committed May 25, 2023
1 parent d3c4580 commit 8974317
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,19 @@ abstract class AbstractMuxHandler<TData>() :

protected fun childRead(id: MuxId, msg: TData) {
val child = streamMap[id]
if (child != null) {
pendingReadComplete += id
child.pipeline().fireChannelRead(msg)
} else {
releaseMessage(msg)
throw ConnectionClosedException("Channel with id $id not opened")
when {
child == null -> {
releaseMessage(msg)
throw ConnectionClosedException("Channel with id $id not opened")
}
child.remoteDisconnected -> {
releaseMessage(msg)
throw ConnectionClosedException("Channel with id $id was closed for sending by remote")
}
else -> {
pendingReadComplete += id
child.pipeline().fireChannelRead(msg)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class MuxChannel<TData>(
val initiator: Boolean
) : AbstractChildChannel(parent.ctx!!.channel(), id) {

private var remoteDisconnected = false
private var localDisconnected = false
var remoteDisconnected = false
var localDisconnected = false

override fun metadata(): ChannelMetadata = ChannelMetadata(true)
override fun localAddress0() =
Expand Down

0 comments on commit 8974317

Please sign in to comment.