3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-14 11:15:51 +00:00

Check whether Peer should stop after each message.

Buffering could cause a delay in stopping if we only depend on socket
being closed.

Resolves issue 161.
This commit is contained in:
Miron Cuperman 2012-03-26 12:15:44 -07:00
parent a77d071d35
commit 92398d2c47

View File

@ -42,7 +42,7 @@ public class Peer {
private final NetworkParameters params;
// Whether the peer loop is supposed to be running or not. Set to false during shutdown so the peer loop
// knows to quit when the socket goes away.
private boolean running;
private volatile boolean running;
private final BlockChain blockChain;
// When an API user explicitly requests a block or transaction from a peer, the InventoryItem is put here
// whilst waiting for the response. Synchronized on itself. Is not used for downloads Peer generates itself.
@ -182,7 +182,7 @@ public class Peer {
running = true;
try {
while (true) {
while (running) {
Message m = conn.readMessage();
// Allow event listeners to filter the message stream. Listeners are allowed to drop messages by