OneSizeFitsQuorum commented on code in PR #3010:
URL: https://github.com/apache/thrift/pull/3010#discussion_r1698123936
##########
lib/java/src/main/java/org/apache/thrift/server/TThreadedSelectorServer.java:
##########
@@ -626,16 +626,23 @@ private synchronized void rebuildSelector() {
LOGGER.error("Create new Selector error.", e);
}
- for (SelectionKey key : oldSelector.selectedKeys()) {
- if (!key.isValid() && key.readyOps() == 0) continue;
+ for (SelectionKey key : oldSelector.keys()) {
+ if (!key.isValid() || key.interestOps() == 0 ||
key.channel().keyFor(newSelector) != null) {
+ continue;
+ }
SelectableChannel channel = key.channel();
Object attachment = key.attachment();
+ int interestOps = key.interestOps();
+ SelectionKey newKey;
try {
if (attachment == null) {
- channel.register(newSelector, key.readyOps());
+ newKey = channel.register(newSelector, interestOpts);
} else {
- channel.register(newSelector, key.readyOps(), attachment);
+ newKey = channel.register(newSelector, interestOpts, attachment);
+ }
+ if (attachment instanceof FrameBuffer) {
Review Comment:
maybe we can move to line 643 as we do not need do anything when attachment
is null
##########
lib/java/src/main/java/org/apache/thrift/server/AbstractNonblockingServer.java:
##########
@@ -518,9 +534,13 @@ private boolean internalRead() {
/** We're done writing, so reset our interest ops and change state
accordingly. */
private void prepareRead() {
- // we can set our interest directly without using the queue because
- // we're in the select thread.
- selectionKey_.interestOps(SelectionKey.OP_READ);
+ if (selectionKey_.isValid()) {
+ // we can set our interest directly without using the queue because
Review Comment:
move these comments to line 537?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]