mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-12 02:05:53 +00:00
Move ping timer cancellation to after channel close during PeerGroup shutdown.
Check if the service is running before trying to re-ping a peer. Attempts to solve a shutdown race. Updates issue 275.
This commit is contained in:
parent
89c611d86b
commit
9a65d4cab8
@ -486,9 +486,6 @@ public class PeerGroup extends AbstractIdleService {
|
|||||||
@Override
|
@Override
|
||||||
protected void shutDown() throws Exception {
|
protected void shutDown() throws Exception {
|
||||||
// This is run on a separate thread by the AbstractIdleService implementation.
|
// This is run on a separate thread by the AbstractIdleService implementation.
|
||||||
synchronized (this) {
|
|
||||||
pingTimer.cancel();
|
|
||||||
}
|
|
||||||
// Blocking close of all sockets. TODO: there is a race condition here, for the solution see:
|
// Blocking close of all sockets. TODO: there is a race condition here, for the solution see:
|
||||||
// http://biasedbit.com/netty-releaseexternalresources-hangs/
|
// http://biasedbit.com/netty-releaseexternalresources-hangs/
|
||||||
channels.close().await();
|
channels.close().await();
|
||||||
@ -497,6 +494,9 @@ public class PeerGroup extends AbstractIdleService {
|
|||||||
for (PeerDiscovery peerDiscovery : peerDiscoverers) {
|
for (PeerDiscovery peerDiscovery : peerDiscoverers) {
|
||||||
peerDiscovery.shutdown();
|
peerDiscovery.shutdown();
|
||||||
}
|
}
|
||||||
|
synchronized (this) {
|
||||||
|
pingTimer.cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -715,7 +715,7 @@ public class PeerGroup extends AbstractIdleService {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
if (!peers.contains(peer))
|
if (!peers.contains(peer) || !PeerGroup.this.isRunning())
|
||||||
return; // Peer was removed/shut down.
|
return; // Peer was removed/shut down.
|
||||||
peer.ping().addListener(this, MoreExecutors.sameThreadExecutor());
|
peer.ping().addListener(this, MoreExecutors.sameThreadExecutor());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user