我的问题是关于更改已注册频道的频道事件循环。
一个通道绑定到一个io-eventloop线程,来自在serverboostrap上设置的EventLoopGroup。好。 但在“协议谈判”之后,我想将某个频道的io-eventloop更改为专用的io-eventloop。 所以我做了这样的事情:
channel.deregister().addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
newIoLoop.register(future.channel()).sync();
}
});
一切顺利,但有一个问题: channel.eventloop已更新,并且将使用此eventloop创建更新的ChannelHandlerContext。 但是channel.pipeline.head仍然绑定到旧的eventloop。 这是预期的行为吗?
这会生成AbstractNioByteChannel.NioByteUnsafe.read()方法引发的异常:
case 2:
// Let the inbound handler drain the buffer and continue reading.
if (read) {
read = false;
pipeline.fireInboundBufferUpdated(); // event fired in the pipeline to try to read some bytes but without waiting for handler executed in another loop
if (!byteBuf.writable()) { // byteBuf may always be full and exception is raised
throw new IllegalStateException(
"an inbound handler whose buffer is full must consume at " +
"least one byte.");
}
}
在我的情况下,在更改频道注册时更改pipeline.head.eventloop将解决此问题。
答案 0 :(得分:0)
这是一个错误..你能否在github上打开关于我们的问题跟踪器的错误报告?
谢谢!