forked from Qortal/qortal
Faster shutdown for Peers doing PROOF part of handshake
This commit is contained in:
parent
2f2d9a664d
commit
7eb5cd55ff
@ -127,6 +127,10 @@ public class Peer extends Thread {
|
||||
|
||||
// Getters / setters
|
||||
|
||||
public boolean isStopping() {
|
||||
return this.isStopping;
|
||||
}
|
||||
|
||||
public PeerData getPeerData() {
|
||||
return this.peerData;
|
||||
}
|
||||
@ -500,7 +504,7 @@ public class Peer extends Thread {
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
LOGGER.debug(String.format("Shutting down peer %s", this));
|
||||
LOGGER.debug(() -> String.format("Shutting down peer %s", this));
|
||||
this.isStopping = true;
|
||||
|
||||
// Shut down pinger
|
||||
@ -525,6 +529,7 @@ public class Peer extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.debug(() -> String.format("Interrupting peer %s", this));
|
||||
this.interrupt();
|
||||
|
||||
// Close socket, which should trigger run() to exit
|
||||
|
@ -64,7 +64,7 @@ public class Proof extends Thread {
|
||||
long nonce;
|
||||
for (nonce = 0; nonce < Long.MAX_VALUE; ++nonce) {
|
||||
// Check whether we're shutting down every so often
|
||||
if ((nonce & 0xff) == 0 && Thread.currentThread().isInterrupted())
|
||||
if ((nonce & 0xff) == 0 && (peer.isStopping() || Thread.currentThread().isInterrupted()))
|
||||
// throw new InterruptedException("Interrupted during peer proof calculation");
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user