我的问题是关于更改已注册频道的eventloop。
一个通道被绑定到一个io-eventloop线程,该线程来自在服务器引导程序上设置的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被更新了,并且将使用这个ChannelHandlerContext创建更新的eventloop。但是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将解决此问题。
发布于 2012-12-12 20:02:34
这是个bug..你能在github上打开我们的问题跟踪器的bug报告吗?
谢谢!
https://stackoverflow.com/questions/13838149
复制相似问题