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) {
|
protected boolean accept(SelectionKey key) {
|
||||||
NioServerSocketChannel channel = (NioServerSocketChannel) key.attachment();
|
NioServerSocketChannel channel = (NioServerSocketChannel) key.attachment();
|
||||||
try {
|
try {
|
||||||
SocketChannel acceptedSocket = channel.socket.accept();
|
boolean handled = false;
|
||||||
if (acceptedSocket != null) {
|
|
||||||
|
// accept all sockets that are waiting atm
|
||||||
|
for (;;) {
|
||||||
|
SocketChannel acceptedSocket = channel.socket.accept();
|
||||||
|
if (acceptedSocket == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
// TODO: Remove the casting stuff
|
// TODO: Remove the casting stuff
|
||||||
ChannelPipeline pipeline =
|
ChannelPipeline pipeline =
|
||||||
channel.getConfig().getPipelineFactory().getPipeline();
|
channel.getConfig().getPipelineFactory().getPipeline();
|
||||||
registerTask(NioAcceptedSocketChannel.create(channel.getFactory(), pipeline, channel,
|
registerTask(NioAcceptedSocketChannel.create(channel.getFactory(), pipeline, channel,
|
||||||
channel.getPipeline().getSink(), acceptedSocket, (NioWorker) this), null);
|
channel.getPipeline().getSink(), acceptedSocket, (NioWorker) this), null);
|
||||||
return true;
|
handled = true;
|
||||||
}
|
}
|
||||||
return false;
|
return handled;
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
// Thrown every second to get ClosedChannelException
|
// Thrown every second to get ClosedChannelException
|
||||||
// raised.
|
// raised.
|
||||||
|
Loading…
Reference in New Issue
Block a user