Check that eventloop's were setup correctly. See #396

This commit is contained in:
Norman Maurer 2012-07-01 22:39:33 +02:00
parent 12112ac857
commit 82834c2f34

View File

@ -17,6 +17,7 @@ package io.netty.channel.socket.aio;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ChannelBufType;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
@ -105,6 +106,14 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne
@Override
protected Runnable doRegister() throws Exception {
Channel parent = parent();
if (parent != null) {
// check that the eventloop instance is shared for the parent and the child
// if not throw an IllegalStateException
if (parent.eventLoop() != eventLoop()) {
throw new IllegalStateException("eventLoop and childEventLoop must be the same!");
}
}
if (ch == null) {
ch = AsynchronousSocketChannel.open(AsynchronousChannelGroup.withThreadPool(eventLoop()));
config = new AioSocketChannelConfig(javaChannel());