Accept all ready sockets for the SelectionKey. See #240
This commit is contained in:
parent
beedd26e1c
commit
f17e56b33b
@ -464,17 +464,22 @@ abstract class AbstractNioWorker implements Worker {
|
|||||||
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