From 3d07e1a10b29b2197e17e60bb5d24430792dd9d1 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sat, 23 May 2015 20:02:46 +0000 Subject: [PATCH] I2CP: Revert part of prior checkin, prevented idle tunnel from opening; (treat INIT as CLOSED) better fix to follow --- core/java/src/net/i2p/client/I2PSessionImpl.java | 15 ++++++++++----- router/java/src/net/i2p/router/RouterVersion.java | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/java/src/net/i2p/client/I2PSessionImpl.java b/core/java/src/net/i2p/client/I2PSessionImpl.java index 7a9ae46c5a..cd6154c96a 100644 --- a/core/java/src/net/i2p/client/I2PSessionImpl.java +++ b/core/java/src/net/i2p/client/I2PSessionImpl.java @@ -824,7 +824,7 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2 */ public boolean isClosed() { synchronized (_stateLock) { - return _state == State.CLOSED; + return _state == State.CLOSED || _state == State.INIT; } } @@ -835,9 +835,13 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2 * @throws I2PSessionException if the message is malformed or there is an error writing it out */ void sendMessage(I2CPMessage message) throws I2PSessionException { - if (isClosed()) { - throw new I2PSessionException("Already closed"); - } else if (_queue != null) { + synchronized (_stateLock) { + if (_state == State.CLOSED) + throw new I2PSessionException("Already closed"); + if (_state == State.INIT) + throw new I2PSessionException("Not open, must call connect() first"); + } + if (_queue != null) { // internal try { if (!_queue.offer(message, MAX_SEND_WAIT)) @@ -846,7 +850,8 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2 throw new I2PSessionException("Interrupted", ie); } } else if (_writer == null) { - throw new I2PSessionException("Already closed"); + // race here + throw new I2PSessionException("Already closed or not open"); } else { _writer.addMessage(message); } diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 285b64c36d..0cd02d33d1 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 28; + public final static long BUILD = 29; /** for example "-test" */ public final static String EXTRA = "-rc"; -- GitLab