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:
jrandom
2004-04-17 00:13:28 +00:00
committed by zzz
parent a859908e83
commit a47c7b8f27

View File

@ -70,7 +70,12 @@ class I2PSessionImpl2 extends I2PSessionImpl {
throws I2PSessionException { throws I2PSessionException {
if (isClosed()) throw new I2PSessionException("Already closed"); if (isClosed()) throw new I2PSessionException("Already closed");
if (SHOULD_COMPRESS) payload = DataHelper.compress(payload); 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); return sendGuaranteed(dest, payload, keyUsed, tagsSent);
} else { } else {
return sendBestEffort(dest, payload, keyUsed, tagsSent); return sendBestEffort(dest, payload, keyUsed, tagsSent);
@ -149,8 +154,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
_log.info("Message send failed after " + state.getElapsed() + "ms with " _log.info("Message send failed after " + state.getElapsed() + "ms with "
+ payload.length + " bytes"); + payload.length + " bytes");
if (_log.shouldLog(Log.ERROR)) if (_log.shouldLog(Log.ERROR))
_log _log.error("Never received *accepted* from the router! dropping and reconnecting");
.error("Never received *accepted* from the router! dropping and reconnecting");
disconnect(); disconnect();
return false; return false;
} }
@ -201,7 +205,10 @@ class I2PSessionImpl2 extends I2PSessionImpl {
_log.debug("Adding sending state " + state.getMessageId() + " / " _log.debug("Adding sending state " + state.getMessageId() + " / "
+ state.getNonce()); + state.getNonce());
_producer.sendMessage(this, dest, nonce, payload, tag, key, sentTags, newKey); _producer.sendMessage(this, dest, nonce, payload, tag, key, sentTags, newKey);
if (isGuaranteed())
state.waitFor(MessageStatusMessage.STATUS_SEND_GUARANTEED_SUCCESS, Clock.getInstance().now() + SEND_TIMEOUT); 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) { synchronized (_sendingStates) {
_sendingStates.remove(state); _sendingStates.remove(state);
} }
@ -214,8 +221,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
+ " was not accepted? (no messageId!!)"); + " was not accepted? (no messageId!!)");
nackTags(state); nackTags(state);
if (_log.shouldLog(Log.CRIT)) if (_log.shouldLog(Log.CRIT))
_log.log(Log.CRIT, _log.log(Log.CRIT, "Disconnecting/reconnecting because we never were accepted!");
"Disconnecting/reconnecting because we never were accepted!");
disconnect(); disconnect();
return false; return false;
} }
@ -244,11 +250,9 @@ class I2PSessionImpl2 extends I2PSessionImpl {
+ state.getTags()); + state.getTags());
if ((state.getTags() != null) && (state.getTags().size() > 0)) { if ((state.getTags() != null) && (state.getTags().size() > 0)) {
if (state.getNewKey() == null) if (state.getNewKey() == null)
SessionKeyManager.getInstance().tagsDelivered(state.getTo().getPublicKey(), state.getKey(), SessionKeyManager.getInstance().tagsDelivered(state.getTo().getPublicKey(), state.getKey(), state.getTags());
state.getTags());
else else
SessionKeyManager.getInstance().tagsDelivered(state.getTo().getPublicKey(), state.getNewKey(), SessionKeyManager.getInstance().tagsDelivered(state.getTo().getPublicKey(), state.getNewKey(), state.getTags());
state.getTags());
} }
} }