4
我的問題是關於更改已註冊頻道的頻道的eventloop。Netty 4 - 更改頻道的eventloop
通道綁定到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被更新,新的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。
謝謝諾曼。 bug報告創建 – Totin
只是修復...感謝報告! –