Skip to content

Commit

Permalink
Clear selectedKeys in OioSctpChannel.doReadMessages
Browse files Browse the repository at this point in the history
Motivation:
The fix for netty#3884 breaks SctpEchoTest because Selector.select will always return 0 if you do not clear last selectedKeys.

Modifications:
Clear readSelector.selectedKeys() if it is not empty.

Result:
SctpEchoTest is green again.
  • Loading branch information
Apache9 committed Dec 21, 2015
1 parent 7c16021 commit d3673a0
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ protected int doReadMessages(List<Object> msgs) throws Exception {
if (!keysSelected) {
return readMessages;
}

// We must clear the selectedKeys because the Selector will never do it. If we do not clear it, the selectionKey
// will always be returned even if there is no data can be read which causes performance issue. And in some
// implementation of Selector, the select method may return 0 if the selectionKey which is ready for process has
// already been in the selectedKeys and cause the keysSelected above to be false even if we actually have
// something to read.
readSelector.selectedKeys().clear();
final RecvByteBufAllocator.Handle allocHandle = unsafe().recvBufAllocHandle();
ByteBuf buffer = allocHandle.allocate(config().getAllocator());
boolean free = true;
Expand Down

0 comments on commit d3673a0

Please sign in to comment.