forked from Qortal/qortal
Networking work-in-progress:
De-register a peer's socket channel OP_READ interest op when producing a ChannelTask for that peer. This should prevent duplicate ChannelTasks for the same peer. Re-register OP_READ once node has read from peer's channel.
This commit is contained in:
parent
6255b2a907
commit
b0e6259073
@ -596,6 +596,10 @@ public class Network {
|
||||
|
||||
try {
|
||||
peer.readChannel();
|
||||
|
||||
LOGGER.trace("Thread {} re-registering OP_READ interestOps on channel: {}",
|
||||
Thread.currentThread().getId(), socketChannel);
|
||||
socketChannel.register(channelSelector, SelectionKey.OP_READ);
|
||||
} catch (IOException e) {
|
||||
if (e.getMessage() != null && e.getMessage().toLowerCase().contains("connection reset")) {
|
||||
peer.disconnect("Connection reset");
|
||||
@ -637,6 +641,12 @@ public class Network {
|
||||
if (channelIterator.hasNext()) {
|
||||
nextSelectionKey = channelIterator.next();
|
||||
channelIterator.remove();
|
||||
|
||||
if (nextSelectionKey.isReadable()) {
|
||||
LOGGER.trace("Thread {} clearing all interestOps on channel: {}",
|
||||
Thread.currentThread().getId(), nextSelectionKey.channel());
|
||||
nextSelectionKey.interestOps(0);
|
||||
}
|
||||
} else {
|
||||
nextSelectionKey = null;
|
||||
channelIterator = null; // Nothing to do so reset iterator to cause new select
|
||||
|
Loading…
x
Reference in New Issue
Block a user