mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-08-01 12:31:23 +00:00
PeerGroup: Closing streams and sockets where necessary
This commit is contained in:
committed by
Andreas Schildbach
parent
8a7aa1ef0d
commit
2969be2ad7
@@ -849,19 +849,23 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
checkState(lock.isHeldByCurrentThread());
|
||||
if (localhostCheckState == LocalhostCheckState.NOT_TRIED) {
|
||||
// Do a fast blocking connect to see if anything is listening.
|
||||
Socket socket = null;
|
||||
try {
|
||||
Socket socket = new Socket();
|
||||
socket = new Socket();
|
||||
socket.connect(new InetSocketAddress(InetAddresses.forString("127.0.0.1"), params.getPort()), vConnectTimeoutMillis);
|
||||
localhostCheckState = LocalhostCheckState.FOUND;
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
// Ignore.
|
||||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
log.info("Localhost peer not detected.");
|
||||
localhostCheckState = LocalhostCheckState.NOT_THERE;
|
||||
} finally {
|
||||
if (socket != null) {
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
// Ignore.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user