Accept all ready sockets for the SelectionKey. See #240
This commit is contained in:
parent
5434bd9645
commit
d0f432b4d4
@ -335,17 +335,22 @@ abstract class SelectorEventLoop extends SingleThreadEventLoop {
|
||||
protected boolean accept(SelectionKey key) {
|
||||
NioServerSocketChannel channel = (NioServerSocketChannel) key.attachment();
|
||||
try {
|
||||
SocketChannel acceptedSocket = channel.socket.accept();
|
||||
if (acceptedSocket != null) {
|
||||
boolean handled = false;
|
||||
|
||||
// accept all sockets that are waiting atm
|
||||
for (;;) {
|
||||
SocketChannel acceptedSocket = channel.socket.accept();
|
||||
if (acceptedSocket == null) {
|
||||
break;
|
||||
}
|
||||
// TODO: Remove the casting stuff
|
||||
ChannelPipeline pipeline =
|
||||
channel.getConfig().getPipelineFactory().getPipeline();
|
||||
registerTask(NioAcceptedSocketChannel.create(channel.getFactory(), pipeline, channel,
|
||||
channel.getPipeline().getSink(), acceptedSocket, (NioWorker) this), null);
|
||||
return true;
|
||||
handled = true;
|
||||
}
|
||||
return false;
|
||||
return handled;
|
||||
} catch (SocketTimeoutException e) {
|
||||
// Thrown every second to get ClosedChannelException
|
||||
// raised.
|
||||
|
Loading…
Reference in New Issue
Block a user