Author: zothar
Date: 2006-06-09 15:30:36 +0000 (Fri, 09 Jun 2006)
New Revision: 9099
Modified:
trunk/freenet/src/freenet/node/PeerNode.java
Log:
Last bit of the restarted sentHandshake()/couldNotSendHandshake() refactor
effort. If there is somehow thought to be a problem with my last few commits,
let's please at least keep this refactored. I'll be around for the next
several hours.
Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java 2006-06-09 15:12:34 UTC
(rev 9098)
+++ trunk/freenet/src/freenet/node/PeerNode.java 2006-06-09 15:30:36 UTC
(rev 9099)
@@ -835,7 +835,11 @@
sendHandshakeTime = now + Node.MIN_TIME_BETWEEN_HANDSHAKE_SENDS
+
node.random.nextInt(Node.RANDOMIZED_TIME_BETWEEN_HANDSHAKE_SENDS);
}
- firstHandshake = false;
+ if(couldSendHandshake) {
+ firstHandshake = false;
+ } else {
+ handshakeIPs = null;
+ }
this.handshakeCount++;
}
// Don't fetch ARKs for peers we have verified (through handshake) to
be incompatible with us
@@ -870,38 +874,7 @@
*/
public void couldNotSendHandshake() {
Logger.minor(this, "couldNotSendHandshake(): "+this);
- long now = -1;
- synchronized(this) {
- now = System.currentTimeMillis();
- if(verifiedIncompatibleOlderVersion ||
verifiedIncompatibleNewerVersion) {
- // Let them know we're here, but have no hope of connecting
- sendHandshakeTime = now + Node.MIN_TIME_BETWEEN_VERSION_SENDS
- +
node.random.nextInt(Node.RANDOMIZED_TIME_BETWEEN_VERSION_SENDS);
- } else if(invalidVersion() && !firstHandshake) {
- sendHandshakeTime = now + Node.MIN_TIME_BETWEEN_VERSION_PROBES
- +
node.random.nextInt(Node.RANDOMIZED_TIME_BETWEEN_VERSION_PROBES);
- } else {
- sendHandshakeTime = now + Node.MIN_TIME_BETWEEN_HANDSHAKE_SENDS
- +
node.random.nextInt(Node.RANDOMIZED_TIME_BETWEEN_HANDSHAKE_SENDS);
- }
- handshakeIPs = null;
- this.handshakeCount++;
- }
- // Don't fetch ARKs for peers we have verified (through handshake) to
be incompatible with us
- if(handshakeCount >= MAX_HANDSHAKE_COUNT &&
!(verifiedIncompatibleOlderVersion || verifiedIncompatibleNewerVersion)) {
- int numARKFetchers = node.getNumARKFetchers();
- if( numARKFetchers >= 30 ) { // Limit concurrent ARK Fetch
Requests to 30 since we UserAlert at 20 disconnected peers anyway
- Logger.minor( this, "Not starting ARK Fetcher
after "+handshakeCount+" failed handshakes for "+getPeer()+" with identity
'"+getIdentityString()+"' because there are already 30 ARK Fetchers running.");
- } else {
- Logger.normal( this, "Starting ARK Fetcher
after "+handshakeCount+" failed handshakes for "+getPeer()+" with identity
'"+getIdentityString()+"'");
- long arkFetcherStartTime1 =
System.currentTimeMillis();
- arkFetcher.start();
- long arkFetcherStartTime2 =
System.currentTimeMillis();
- if((arkFetcherStartTime2 -
arkFetcherStartTime1) > 500) {
- Logger.normal(this,
"arkFetcherStartTime2 is more than half a second after arkFetcherStartTime1
("+(arkFetcherStartTime2 - arkFetcherStartTime1)+") working on "+myName);
- }
- }
- }
+ calcNextHandshake(false);
}
/**