mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-24 06:47:54 +01:00
Fixes for r165 code review
This commit is contained in:
parent
0c8638ae2e
commit
381cda1ff2
1 changed files with 5 additions and 7 deletions
|
@ -95,7 +95,7 @@ public class Peer {
|
||||||
*
|
*
|
||||||
* @throws PeerException when there is a temporary problem with the peer and we should retry later
|
* @throws PeerException when there is a temporary problem with the peer and we should retry later
|
||||||
*/
|
*/
|
||||||
public void connect() throws PeerException {
|
public synchronized void connect() throws PeerException {
|
||||||
try {
|
try {
|
||||||
conn = new NetworkConnection(address, params, bestHeight, 60000);
|
conn = new NetworkConnection(address, params, bestHeight, 60000);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
@ -136,11 +136,11 @@ public class Peer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
disconnect();
|
|
||||||
if (!running) {
|
if (!running) {
|
||||||
// This exception was expected because we are tearing down the socket as part of quitting.
|
// This exception was expected because we are tearing down the socket as part of quitting.
|
||||||
log.info("Shutting down peer loop");
|
log.info("Shutting down peer loop");
|
||||||
} else {
|
} else {
|
||||||
|
disconnect();
|
||||||
throw new PeerException(e);
|
throw new PeerException(e);
|
||||||
}
|
}
|
||||||
} catch (ProtocolException e) {
|
} catch (ProtocolException e) {
|
||||||
|
@ -398,10 +398,8 @@ public class Peer {
|
||||||
/**
|
/**
|
||||||
* Terminates the network connection and stops the message handling loop.
|
* Terminates the network connection and stops the message handling loop.
|
||||||
*/
|
*/
|
||||||
public void disconnect() {
|
public synchronized void disconnect() {
|
||||||
synchronized (this) {
|
|
||||||
running = false;
|
running = false;
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
// This is the correct way to stop an IO bound loop
|
// This is the correct way to stop an IO bound loop
|
||||||
if (conn != null)
|
if (conn != null)
|
||||||
|
|
Loading…
Add table
Reference in a new issue