mirror of
https://github.com/Qortal/qortal.git
synced 2025-02-16 04:05:48 +00:00
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 {
|
try {
|
||||||
peer.readChannel();
|
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) {
|
} catch (IOException e) {
|
||||||
if (e.getMessage() != null && e.getMessage().toLowerCase().contains("connection reset")) {
|
if (e.getMessage() != null && e.getMessage().toLowerCase().contains("connection reset")) {
|
||||||
peer.disconnect("Connection reset");
|
peer.disconnect("Connection reset");
|
||||||
@ -637,6 +641,12 @@ public class Network {
|
|||||||
if (channelIterator.hasNext()) {
|
if (channelIterator.hasNext()) {
|
||||||
nextSelectionKey = channelIterator.next();
|
nextSelectionKey = channelIterator.next();
|
||||||
channelIterator.remove();
|
channelIterator.remove();
|
||||||
|
|
||||||
|
if (nextSelectionKey.isReadable()) {
|
||||||
|
LOGGER.trace("Thread {} clearing all interestOps on channel: {}",
|
||||||
|
Thread.currentThread().getId(), nextSelectionKey.channel());
|
||||||
|
nextSelectionKey.interestOps(0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
nextSelectionKey = null;
|
nextSelectionKey = null;
|
||||||
channelIterator = null; // Nothing to do so reset iterator to cause new select
|
channelIterator = null; // Nothing to do so reset iterator to cause new select
|
||||||
|
Loading…
x
Reference in New Issue
Block a user