mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-31 20:11:23 +00:00
PeerGroup: Locking fix in newly added method. A bit more logging.
This commit is contained in:
@@ -884,6 +884,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
torClient.stop();
|
||||
}
|
||||
vRunning = false;
|
||||
log.info("Stopped.");
|
||||
} catch (Throwable e) {
|
||||
log.error("Exception when shutting down", e); // The executor swallows exceptions :(
|
||||
}
|
||||
@@ -897,6 +898,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
public void stop() {
|
||||
try {
|
||||
stopAsync();
|
||||
log.info("Awaiting PeerGroup shutdown ...");
|
||||
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -1525,6 +1527,8 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
* @return a future that will be triggered when the number of connected peers implementing protocolVersion or higher >= numPeers
|
||||
*/
|
||||
public ListenableFuture<List<Peer>> waitForPeersWithServiceMask(final int numPeers, final int mask) {
|
||||
lock.lock();
|
||||
try {
|
||||
List<Peer> foundPeers = findPeersWithServiceMask(mask);
|
||||
if (foundPeers.size() >= numPeers)
|
||||
return Futures.immediateFuture(foundPeers);
|
||||
@@ -1540,6 +1544,9 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
}
|
||||
});
|
||||
return future;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user