1
0
mirror of https://github.com/square/okhttp.git synced 2026-01-27 04:22:07 +03:00

Synchronize access to idleStartTimeNs.

See https://github.com/square/okhttp/issues/145
This commit is contained in:
jwilson
2013-04-11 14:53:27 -07:00
parent 94d9d88c90
commit 12b35d6a62

View File

@@ -139,17 +139,17 @@ public final class SpdyConnection implements Closeable {
return stream;
}
private void setIdle(boolean value) {
private synchronized void setIdle(boolean value) {
idleStartTimeNs = value ? System.nanoTime() : 0L;
}
/** Returns true if this connection is idle. */
public boolean isIdle() {
public synchronized boolean isIdle() {
return idleStartTimeNs != 0L;
}
/** Returns the time in ns when this connection became idle or 0L if connection is not idle. */
public long getIdleStartTimeNs() {
public synchronized long getIdleStartTimeNs() {
return idleStartTimeNs;
}