首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Netty 4-更改频道的eventloop

Netty 4-更改频道的eventloop
EN

Stack Overflow用户
提问于 2012-12-12 18:53:24
回答 1查看 958关注 0票数 4

我的问题是关于更改已注册频道的eventloop。

一个通道被绑定到一个io-eventloop线程,该线程来自在服务器引导程序上设置的EventLoopGroup。好的。但是在“协议协商”之后,我想要将某个通道的io-eventloop更改为专用的io-eventloop。所以我这样做:

代码语言:javascript
复制
        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()方法引发的异常:

代码语言:javascript
复制
  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将解决此问题。

EN

回答 1

Stack Overflow用户

发布于 2012-12-12 20:02:34

这是个bug..你能在github上打开我们的问题跟踪器的bug报告吗?

谢谢!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13838149

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档