From 93fd045488565879bc40a6d942e165a9148351ca Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Mon, 10 Dec 2012 23:50:21 +0100 Subject: [PATCH] Lock the ping time accessors correctly. --- core/src/main/java/com/google/bitcoin/core/Peer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/google/bitcoin/core/Peer.java b/core/src/main/java/com/google/bitcoin/core/Peer.java index e4e7ae38..f9f2c810 100644 --- a/core/src/main/java/com/google/bitcoin/core/Peer.java +++ b/core/src/main/java/com/google/bitcoin/core/Peer.java @@ -818,7 +818,7 @@ public class Peer { * Returns the elapsed time of the last ping/pong cycle. If {@link com.google.bitcoin.core.Peer#ping()} has never * been called or we did not hear back the "pong" message yet, returns {@link Long#MAX_VALUE}. */ - public long getLastPingTime() { + public synchronized long getLastPingTime() { if (lastPingTimes == null) return Long.MAX_VALUE; return lastPingTimes[lastPingTimes.length - 1]; @@ -829,7 +829,7 @@ public class Peer { * been called or we did not hear back the "pong" message yet, returns {@link Long#MAX_VALUE}. The moving average * window is 5 buckets. */ - public long getPingTime() { + public synchronized long getPingTime() { if (lastPingTimes == null) return Long.MAX_VALUE; long sum = 0;