Some system calls can be called later to improve accept() performance

This commit is contained in:
Trustin Lee 2009-07-08 18:13:56 +00:00
parent f414e425e7
commit 14e8f0a75e
2 changed files with 7 additions and 11 deletions

View File

@ -24,11 +24,9 @@ package org.jboss.netty.channel.socket.nio;
import static org.jboss.netty.channel.Channels.*;
import java.io.IOException;
import java.nio.channels.SocketChannel;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelException;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelSink;
@ -50,14 +48,8 @@ final class NioAcceptedSocketChannel extends NioSocketChannel {
super(parent, factory, pipeline, sink, socket, worker);
try {
socket.configureBlocking(false);
} catch (IOException e) {
throw new ChannelException("Failed to enter non-blocking mode.", e);
}
fireChannelOpen(this);
fireChannelBound(this, socket.socket().getLocalSocketAddress());
fireChannelConnected(this, socket.socket().getRemoteSocketAddress());
fireChannelBound(this, getLocalAddress());
fireChannelConnected(this, getRemoteAddress());
}
}

View File

@ -716,6 +716,10 @@ class NioWorker implements Runnable {
}
try {
if (server) {
channel.socket.configureBlocking(false);
}
synchronized (channel.interestOpsLock) {
channel.socket.register(
selector, channel.getRawInterestOps(), channel);
@ -723,7 +727,7 @@ class NioWorker implements Runnable {
if (future != null) {
future.setSuccess();
}
} catch (ClosedChannelException e) {
} catch (IOException e) {
if (future != null) {
future.setFailure(e);
}