I2CP: Revert part of prior checkin, prevented idle tunnel from opening;

(treat INIT as CLOSED) better fix to follow
This commit is contained in:
zzz
2015-05-23 20:02:46 +00:00
parent 195171f9ed
commit 3d07e1a10b
2 changed files with 11 additions and 6 deletions

View File

@ -824,7 +824,7 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
*/ */
public boolean isClosed() { public boolean isClosed() {
synchronized (_stateLock) { 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 * @throws I2PSessionException if the message is malformed or there is an error writing it out
*/ */
void sendMessage(I2CPMessage message) throws I2PSessionException { void sendMessage(I2CPMessage message) throws I2PSessionException {
if (isClosed()) { synchronized (_stateLock) {
throw new I2PSessionException("Already closed"); if (_state == State.CLOSED)
} else if (_queue != null) { throw new I2PSessionException("Already closed");
if (_state == State.INIT)
throw new I2PSessionException("Not open, must call connect() first");
}
if (_queue != null) {
// internal // internal
try { try {
if (!_queue.offer(message, MAX_SEND_WAIT)) if (!_queue.offer(message, MAX_SEND_WAIT))
@ -846,7 +850,8 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
throw new I2PSessionException("Interrupted", ie); throw new I2PSessionException("Interrupted", ie);
} }
} else if (_writer == null) { } else if (_writer == null) {
throw new I2PSessionException("Already closed"); // race here
throw new I2PSessionException("Already closed or not open");
} else { } else {
_writer.addMessage(message); _writer.addMessage(message);
} }

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 28; public final static long BUILD = 29;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = "-rc"; public final static String EXTRA = "-rc";