[freenet-cvs] r16706 - trunk/freenet/src/freenet/node

Matthew Toseland toad at amphibian.dyndns.org
Wed Dec 19 18:15:53 UTC 2007


On Tuesday 18 December 2007 22:47, robert at freenetproject.org wrote:
> Author: robert
> Date: 2007-12-18 22:47:49 +0000 (Tue, 18 Dec 2007)
> New Revision: 16706
> 
> Modified:
>    trunk/freenet/src/freenet/node/CHKInsertSender.java
> Log:
> Restore previous behavior for AIMD (total RTT)

Okay, this commit:
- Reinstates completedTransfer(), exactly as it was.
- Deletes the unused variable completionTimedOut.
- Drops the timeout parameter from completed(timeout, success) as it is never 
used.
- And renames it from completed(success) to receivedNotice(success).

Now, combining the two:
- A few trivial code simplifications: if(x) blah(true) else blah(false) -> 
blah(x).
- Code simplifications in completed*() which don't have any practical impact 
although they change the logic: if(blah) blahInner = true -> blahInner = 
blah;
- Rename some threads.
- Delete Sender and merge it into AwaitingCompletion.
- Delete unused timeout parameter from completed() and rename to 
receivedNotice().
- Logging and comments.
> 
> Modified: trunk/freenet/src/freenet/node/CHKInsertSender.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/CHKInsertSender.java	2007-12-18 22:15:14 
UTC (rev 16705)
> +++ trunk/freenet/src/freenet/node/CHKInsertSender.java	2007-12-18 22:47:49 
UTC (rev 16706)
> @@ -33,9 +33,7 @@
>  		 * or failure of dependant transfers from that node?
>  		 * Includes timing out. */
>  		boolean receivedCompletionNotice;
> -		/** Timed out - didn't receive completion notice in
> -		 * the allotted time?? */
> -		boolean completionTimedOut;
> +
>  		/** Was the notification of successful transfer? */
>  		boolean completionSucceeded;
>  		
> @@ -57,23 +55,32 @@
>  			freenet.support.Logger.OSThread.logPID(this);
>  			try {
>  				bt.send(node.executor);
> -				if(bt.failedDueToOverload()) {
> -					this.completed(false, false);
> -				} else {
> -					this.completed(false, true);
> -				}
> +				this.completedTransfer(bt.failedDueToOverload());
>  			} catch (Throwable t) {
> -				this.completed(false, false);
> +				this.completedTransfer(false);
>  				Logger.error(this, "Caught "+t, t);
>  			}
>  		}
>  		
> -		void completed(boolean timeout, boolean success) {
> -			if (logMINOR) Logger.minor(this, "CHKInsert-BackgroundTransfer complete 
(timeout="+timeout+", success="+success);
> -			if (success && timeout)
> -				throw new IllegalArgumentException("how can a request successfully 
timeout?");
> +		void completedTransfer(boolean success) {
>  			synchronized(this) {
> -				completionTimedOut = timeout;
> +				transferSucceeded = success;
> +				completedTransfer = true;
> +				notifyAll();
> +			}
> +			synchronized(backgroundTransfers) {
> +				backgroundTransfers.notifyAll();
> +			}
> +			if(!success) {
> +				synchronized(CHKInsertSender.this) {
> +					transferTimedOut = true;
> +					CHKInsertSender.this.notifyAll();
> +				}
> +			}
> +		}
> +		
> +		void receivedNotice(boolean success) {
> +			synchronized(this) {
>  				completionSucceeded = success;
>  				receivedCompletionNotice = true;
>  				notifyAll();
> @@ -86,8 +93,9 @@
>  					transferTimedOut = true;
>  					CHKInsertSender.this.notifyAll();
>  				}
> -			}
> +			}			
>  		}
> +		
>  	}
>  	
>  	CHKInsertSender(NodeCHK myKey, long uid, byte[] headers, short htl, 
> @@ -701,7 +709,7 @@
>  							PeerNode p = transfers[i].pn;
>  							if(p == pn) {
>  								boolean anyTimedOut = m.getBoolean(DMT.ANY_TIMED_OUT);
> -								transfers[i].completed(false, !anyTimedOut);
> +								transfers[i].receivedNotice(!anyTimedOut);
>  								if(anyTimedOut) {
>  									synchronized(CHKInsertSender.this) {
>  										if(!transferTimedOut) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://emu.freenetproject.org/pipermail/cvs/attachments/20071219/b8d99ac3/attachment.pgp 


More information about the cvs mailing list