forked from I2P_Developers/i2p.i2p
always send as a guaranteed message (but block as before) - this lets
udp-esque users get transparent sessionKey/sessionTag management. we'll probably refactor mode=guaranteed/best_effort into two concepts later, dealing with blocking and encryption seperately. logging and formatting fixes
This commit is contained in:
@@ -70,7 +70,12 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
||||
throws I2PSessionException {
|
||||
if (isClosed()) throw new I2PSessionException("Already closed");
|
||||
if (SHOULD_COMPRESS) payload = DataHelper.compress(payload);
|
||||
if (isGuaranteed()) {
|
||||
// we always send as guaranteed (so we get the session keys/tags acked),
|
||||
// but only block until the appropriate event has been reached (guaranteed
|
||||
// success or accepted). we may want to break this out into a seperate
|
||||
// attribute, allowing both nonblocking sends and transparently managed keys,
|
||||
// as well as the nonblocking sends with application managed keys. Later.
|
||||
if (isGuaranteed() || true) {
|
||||
return sendGuaranteed(dest, payload, keyUsed, tagsSent);
|
||||
} else {
|
||||
return sendBestEffort(dest, payload, keyUsed, tagsSent);
|
||||
@@ -149,8 +154,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
||||
_log.info("Message send failed after " + state.getElapsed() + "ms with "
|
||||
+ payload.length + " bytes");
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log
|
||||
.error("Never received *accepted* from the router! dropping and reconnecting");
|
||||
_log.error("Never received *accepted* from the router! dropping and reconnecting");
|
||||
disconnect();
|
||||
return false;
|
||||
}
|
||||
@@ -201,7 +205,10 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
||||
_log.debug("Adding sending state " + state.getMessageId() + " / "
|
||||
+ state.getNonce());
|
||||
_producer.sendMessage(this, dest, nonce, payload, tag, key, sentTags, newKey);
|
||||
if (isGuaranteed())
|
||||
state.waitFor(MessageStatusMessage.STATUS_SEND_GUARANTEED_SUCCESS, Clock.getInstance().now() + SEND_TIMEOUT);
|
||||
else
|
||||
state.waitFor(MessageStatusMessage.STATUS_SEND_ACCEPTED, Clock.getInstance().now() + SEND_TIMEOUT);
|
||||
synchronized (_sendingStates) {
|
||||
_sendingStates.remove(state);
|
||||
}
|
||||
@@ -214,8 +221,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
||||
+ " was not accepted? (no messageId!!)");
|
||||
nackTags(state);
|
||||
if (_log.shouldLog(Log.CRIT))
|
||||
_log.log(Log.CRIT,
|
||||
"Disconnecting/reconnecting because we never were accepted!");
|
||||
_log.log(Log.CRIT, "Disconnecting/reconnecting because we never were accepted!");
|
||||
disconnect();
|
||||
return false;
|
||||
}
|
||||
@@ -244,11 +250,9 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
||||
+ state.getTags());
|
||||
if ((state.getTags() != null) && (state.getTags().size() > 0)) {
|
||||
if (state.getNewKey() == null)
|
||||
SessionKeyManager.getInstance().tagsDelivered(state.getTo().getPublicKey(), state.getKey(),
|
||||
state.getTags());
|
||||
SessionKeyManager.getInstance().tagsDelivered(state.getTo().getPublicKey(), state.getKey(), state.getTags());
|
||||
else
|
||||
SessionKeyManager.getInstance().tagsDelivered(state.getTo().getPublicKey(), state.getNewKey(),
|
||||
state.getTags());
|
||||
SessionKeyManager.getInstance().tagsDelivered(state.getTo().getPublicKey(), state.getNewKey(), state.getTags());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user