3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-12 18:25:51 +00:00

Don't hold the Peer lock whilst invoking a ping callback.

This commit is contained in:
Mike Hearn 2012-12-24 23:47:14 +00:00
parent eb7c4be136
commit ffc953abc8

View File

@ -846,14 +846,16 @@ public class Peer {
return (long)((double) sum / lastPingTimes.length);
}
private synchronized void processPong(Pong m) {
ListIterator<PendingPing> it = pendingPings.listIterator();
private void processPong(Pong m) {
PendingPing ping = null;
while (it.hasNext()) {
ping = it.next();
if (m.getNonce() == ping.nonce) {
it.remove();
break;
synchronized (this) {
ListIterator<PendingPing> it = pendingPings.listIterator();
while (it.hasNext()) {
ping = it.next();
if (m.getNonce() == ping.nonce) {
it.remove();
break;
}
}
}
// This line may trigger an event listener being run on the same thread, if one is attached to the