Author: toad
Date: 2005-12-05 19:42:04 +0000 (Mon, 05 Dec 2005)
New Revision: 7672
Modified:
trunk/freenet/src/freenet/client/SplitInserter.java
trunk/freenet/src/freenet/node/InsertHandler.java
trunk/freenet/src/freenet/node/Node.java
trunk/freenet/src/freenet/node/NodeDispatcher.java
trunk/freenet/src/freenet/node/RequestSender.java
trunk/freenet/src/freenet/node/Version.java
Log:
272:
Don't unlock ID so early in requests. Always wait for the completion. (Don't
wait for the completion in the receive handler!).
Fix minor one-too-many-redirects splitfile bug.
Logging
Dead code removal.
Modified: trunk/freenet/src/freenet/client/SplitInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/SplitInserter.java 2005-12-05 19:26:22 UTC
(rev 7671)
+++ trunk/freenet/src/freenet/client/SplitInserter.java 2005-12-05 19:42:04 UTC
(rev 7672)
@@ -132,7 +132,7 @@
if(inserter == null)
inserter = new FileInserter(ctx);
- InsertBlock mblock = new InsertBlock(mbucket,
clientMetadata, FreenetURI.EMPTY_CHK_URI);
+ InsertBlock mblock = new InsertBlock(mbucket, null,
FreenetURI.EMPTY_CHK_URI);
// FIXME probably should uncomment below so it doesn't
get inserted at all?
// FIXME this is a hack for small network support...
but we will need that IRL... hmmm
Modified: trunk/freenet/src/freenet/node/InsertHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/InsertHandler.java 2005-12-05 19:26:22 UTC
(rev 7671)
+++ trunk/freenet/src/freenet/node/InsertHandler.java 2005-12-05 19:42:04 UTC
(rev 7672)
@@ -238,13 +238,17 @@
* verifies, then commit it.
*/
private void finish() {
- Message toSend = null;
+ Logger.minor(this, "Finishing");
+ maybeCommit();
+
+ Logger.minor(this, "Waiting for completion");
// Wait for completion
boolean sentCompletionWasSet;
synchronized(sentCompletionLock) {
sentCompletionWasSet = sentCompletion;
sentCompletion = true;
}
+
if(!sentCompletionWasSet) {
while(true) {
synchronized(sender) {
@@ -268,14 +272,19 @@
// May need to commit anyway...
}
}
+ }
+
+ private void maybeCommit() {
+ Message toSend = null;
synchronized(this) { // REDFLAG do not use synch(this) for any other
purpose!
- if(prb != null || prb.isAborted()) return;
+ if(prb == null || prb.isAborted()) return;
try {
if(!canCommit) return;
if(!prb.allReceived()) return;
CHKBlock block = new CHKBlock(prb.getBlock(), headers, key);
node.store(block);
+ Logger.minor(this, "Committed");
} catch (CHKVerifyException e) {
Logger.error(this, "Verify failed in InsertHandler: "+e+" -
headers: "+HexUtil.bytesToHex(headers), e);
toSend = DMT.createFNPDataInsertRejected(uid,
DMT.DATA_INSERT_REJECTED_VERIFY_FAILED);
@@ -291,20 +300,10 @@
// :(
Logger.minor(this, "Lost connection in "+this+" when sending
FNPDataInsertRejected");
}
- } else if(sender != null && sender.getStatus() == InsertSender.SUCCESS
&& !sentSuccess) {
- sentSuccess = true;
- // Succeeded! Yay!
- Message msg = DMT.createFNPInsertReply(uid);
- try {
- source.send(msg);
- } catch (NotConnectedException e) {
- // Ugh
- Logger.normal(this, "Finished InsertHandler but can't
tell original node!: "+e);
- }
}
- }
-
- /** Has the receive failed? If so, there's not much more that can be
done... */
+ }
+
+ /** Has the receive failed? If so, there's not much more that can be
done... */
private boolean receiveFailed;
public class DataReceiver implements Runnable {
@@ -314,7 +313,7 @@
try {
br.receive();
Logger.minor(this, "Received data for "+InsertHandler.this);
- finish();
+ maybeCommit();
} catch (RetrievalException e) {
receiveFailed = true;
runThread.interrupt();
@@ -331,6 +330,10 @@
}
}
+ public String toString() {
+ return super.toString()+" for "+uid;
+ }
+
}
}
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2005-12-05 19:26:22 UTC (rev
7671)
+++ trunk/freenet/src/freenet/node/Node.java 2005-12-05 19:42:04 UTC (rev
7672)
@@ -855,6 +855,7 @@
}
public boolean lockUID(long uid) {
+ Logger.minor(this, "Locking "+uid);
Long l = new Long(uid);
synchronized(runningUIDs) {
if(runningUIDs.contains(l)) return false;
@@ -864,6 +865,7 @@
}
public void unlockUID(long uid) {
+ Logger.minor(this, "Unlocking "+uid);
Long l = new Long(uid);
completed(uid);
synchronized(runningUIDs) {
Modified: trunk/freenet/src/freenet/node/NodeDispatcher.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeDispatcher.java 2005-12-05 19:26:22 UTC
(rev 7671)
+++ trunk/freenet/src/freenet/node/NodeDispatcher.java 2005-12-05 19:42:04 UTC
(rev 7672)
@@ -114,6 +114,8 @@
Logger.normal(this, "Rejecting insert request: "+e);
}
return true;
+ } else {
+ Logger.minor(this, "Locked "+id);
}
//if(!node.lockUID(id)) return false;
RequestHandler rh = new RequestHandler(m, id, node);
Modified: trunk/freenet/src/freenet/node/RequestSender.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestSender.java 2005-12-05 19:26:22 UTC
(rev 7671)
+++ trunk/freenet/src/freenet/node/RequestSender.java 2005-12-05 19:42:04 UTC
(rev 7672)
@@ -306,6 +306,7 @@
} catch (Throwable t) {
Logger.error(this, "Caught "+t, t);
} finally {
+ Logger.minor(this, "Leaving RequestSender.run() for "+uid);
node.completed(uid);
node.removeSender(key, origHTL, this);
}
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2005-12-05 19:26:22 UTC (rev
7671)
+++ trunk/freenet/src/freenet/node/Version.java 2005-12-05 19:42:04 UTC (rev
7672)
@@ -20,10 +20,10 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- public static final int buildNumber = 271;
+ public static final int buildNumber = 272;
/** Oldest build of Fred we will talk to */
- public static final int lastGoodBuild = 271;
+ public static final int lastGoodBuild = 272;
/** The highest reported build of fred */
public static int highestSeenBuild = buildNumber;