Wrong. The below will not disconnect if we rekeyed due to transferred data
rather than due to time.
On Saturday 01 December 2007 15:14, nextgens at freenetproject.org wrote:
> Author: nextgens
> Date: 2007-12-01 15:14:36 +0000 (Sat, 01 Dec 2007)
> New Revision: 16182
>
> Modified:
> trunk/freenet/src/freenet/node/PeerNode.java
> Log:
> JFK: simplify|fix the logic of rekeying
>
> Modified: trunk/freenet/src/freenet/node/PeerNode.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/PeerNode.java 2007-12-01 14:50:20 UTC
(rev 16181)
> +++ trunk/freenet/src/freenet/node/PeerNode.java 2007-12-01 15:14:36 UTC
(rev 16182)
> @@ -899,30 +899,33 @@
>
> protected void maybeRekey() {
> long now = System.currentTimeMillis();
> - boolean hasRekeyed = false;
> - if(hasLiveHandshake(now))
> - return;
> -
> + boolean shouldDisconnect = false;
> + boolean shouldReturn = false;
> + boolean shouldRekey = false;
> long timeWhenRekeyingShouldOccur = 0;
> - synchronized(this) {
> - if(isRekeying || !isConnected)
> - return;
> +
> + synchronized (this) {
> timeWhenRekeyingShouldOccur = timeLastRekeyed +
FNPPacketMangler.SESSION_KEY_REKEYING_INTERVAL;
> - if((timeWhenRekeyingShouldOccur < now) ||
(totalBytesExchangedWithCurrentTracker >
FNPPacketMangler.AMOUNT_OF_BYTES_ALLOWED_BEFORE_WE_REKEY)) {
> - hasRekeyed = true;
> + shouldDisconnect = (timeWhenRekeyingShouldOccur +
FNPPacketMangler.MAX_SESSION_KEY_REKEYING_DELAY < now) && isRekeying;
> + shouldReturn = isRekeying || !isConnected;
> + shouldRekey = (timeWhenRekeyingShouldOccur < now) ||
(totalBytesExchangedWithCurrentTracker >
FNPPacketMangler.AMOUNT_OF_BYTES_ALLOWED_BEFORE_WE_REKEY);
> + }
> +
> + if(shouldDisconnect) {
> + String time =
TimeUtil.formatTime(FNPPacketMangler.MAX_SESSION_KEY_REKEYING_DELAY);
> + System.err.println("The peer (" + this + ") has been
> asked to rekey " +
time + " ago... force disconnect.");
> + Logger.error(this, "The peer (" + this + ") has been
> asked to rekey " +
time + " ago... force disconnect.");
> + forceDisconnect();
> + } else if (shouldReturn || hasLiveHandshake(now)) {
> + return;
> + } else if(shouldRekey) {
> + synchronized(this) {
> isRekeying = true;
> sendHandshakeTime = now; // Immediately
> ctx = null;
> }
> + Logger.normal(this, "We are asking for the key to be
> renewed (" +
this.detectedPeer + ')');
> }
> -
> - if(timeWhenRekeyingShouldOccur +
FNPPacketMangler.MAX_SESSION_KEY_REKEYING_DELAY < now) {
> - Logger.error(this, "The peer (" + this + ") has been
> asked to rekey " +
TimeUtil.formatTime(FNPPacketMangler.MAX_SESSION_KEY_REKEYING_DELAY) + "
ago... force disconnect.");
> - forceDisconnect();
> - }
> -
> - if(hasRekeyed)
> - Logger.normal(this, "We are asking for the key to be
> renewed (" +
this.detectedPeer + ')');
> }
>
> /**
>
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20071201/8f3325ab/attachment.pgp>