Skip to content

Commit

Permalink
Changed the order of checking for connectable and readable keys (http…
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Aug 16, 2021
1 parent 3f419f7 commit 0e9a071
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/org/jgroups/blocks/cs/NioBaseServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,20 @@ public void run() {
try {
if(!key.isValid())
continue;
if(key.isReadable())
conn.receive();
if(key.isWritable())
conn.send();
if(key.isAcceptable())
handleAccept(key);
else if(key.isConnectable()) {
// a key can be connectable *and* readable (https://issues.redhat.com/browse/JGRP-2531)
if(key.isConnectable()) {
SocketChannel ch=(SocketChannel)key.channel();
if(ch.finishConnect() || ch.isConnected()) {
conn.clearSelectionKey(SelectionKey.OP_CONNECT);
conn.connected(true);
}
}
if(key.isReadable())
conn.receive();
if(key.isWritable())
conn.send();
if(key.isAcceptable())
handleAccept(key);
}
catch(Throwable ex) {
closeConnection(conn);
Expand Down

0 comments on commit 0e9a071

Please sign in to comment.