Author: toad
Date: 2007-09-20 22:12:14 +0000 (Thu, 20 Sep 2007)
New Revision: 15216
Modified:
trunk/freenet/src/freenet/clients/http/ConnectionsToadlet.java
trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
trunk/freenet/src/freenet/node/PeerManager.java
trunk/freenet/src/freenet/node/PeerNode.java
Log:
Indicate on the connections page etc when a node is disconnecting i.e. we've
started the process but can't complete it until we've given the node a chance
of receiving our message asking it to remove us.
Modified: trunk/freenet/src/freenet/clients/http/ConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ConnectionsToadlet.java
2007-09-20 22:00:22 UTC (rev 15215)
+++ trunk/freenet/src/freenet/clients/http/ConnectionsToadlet.java
2007-09-20 22:12:14 UTC (rev 15216)
@@ -173,6 +173,7 @@
int numberOfListenOnly =
PeerNodeStatus.getPeerStatusCount(peerNodeStatuses,
PeerManager.PEER_NODE_STATUS_LISTEN_ONLY);
int numberOfClockProblem =
PeerNodeStatus.getPeerStatusCount(peerNodeStatuses,
PeerManager.PEER_NODE_STATUS_CLOCK_PROBLEM);
int numberOfConnError =
PeerNodeStatus.getPeerStatusCount(peerNodeStatuses,
PeerManager.PEER_NODE_STATUS_CONN_ERROR);
+ int numberOfDisconnecting =
PeerNodeStatus.getPeerStatusCount(peerNodeStatuses,
PeerManager.PEER_NODE_STATUS_DISCONNECTING);
int numberOfSimpleConnected = numberOfConnected +
numberOfRoutingBackedOff;
int numberOfNotConnected = numberOfTooNew + numberOfTooOld +
numberOfDisconnected + numberOfNeverConnected + numberOfDisabled +
numberOfBursting + numberOfListening + numberOfListenOnly +
numberOfClockProblem + numberOfConnError;
@@ -313,6 +314,11 @@
peerStatsListenOnlyListItem.addChild("span",
new String[] { "class", "title", "style" }, new String[] {
"peer_clock_problem", l10n("connError"), "border-bottom: 1px dotted; cursor:
help;" }, l10n("connErrorShort"));
peerStatsListenOnlyListItem.addChild("span",
":\u00a0" + numberOfConnError);
}
+ if (numberOfDisconnecting > 0) {
+ HTMLNode peerStatsListenOnlyListItem =
peerStatsList.addChild("li").addChild("span");
+ peerStatsListenOnlyListItem.addChild("span",
new String[] { "class", "title", "style" }, new String[] {
"peer_clock_problem", l10n("connError"), "border-bottom: 1px dotted; cursor:
help;" }, l10n("disconnectingShort"));
+ peerStatsListenOnlyListItem.addChild("span",
":\u00a0" + numberOfConnError);
+ }
// Peer routing backoff reason box
if(advancedModeEnabled) {
Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2007-09-20
22:00:22 UTC (rev 15215)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2007-09-20
22:12:14 UTC (rev 15216)
@@ -114,6 +114,8 @@
DarknetConnectionsToadlet.disabledShort=Disabled
DarknetConnectionsToadlet.enterDescription=Enter description:
DarknetConnectionsToadlet.connError=Connection failed (buggy node?)
+DarknetConnectionsToadlet.disconnectingShort=Disconnecting
+DarknetConnectionsToadlet.disconnecting=Disconnecting (we are currently
removing the node, we need to tell it to go away and this can take a short time)
DarknetConnectionsToadlet.connErrorShort=Connection Error
DarknetConnectionsToadlet.failedToAddNodeInternalError=Unable to parse the
given text as a node reference. Please report the following to the developers:
DarknetConnectionsToadlet.failedToAddNodeInternalErrorTitle=Failed to Add
Node: Internal Error
Modified: trunk/freenet/src/freenet/node/PeerManager.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerManager.java 2007-09-20 22:00:22 UTC
(rev 15215)
+++ trunk/freenet/src/freenet/node/PeerManager.java 2007-09-20 22:12:14 UTC
(rev 15216)
@@ -94,6 +94,7 @@
public static final int PEER_NODE_STATUS_LISTEN_ONLY = 10;
public static final int PEER_NODE_STATUS_CLOCK_PROBLEM = 11;
public static final int PEER_NODE_STATUS_CONN_ERROR = 12;
+ public static final int PEER_NODE_STATUS_DISCONNECTING = 13;
/**
* Create a PeerManager by reading a list of peers from
@@ -381,6 +382,7 @@
synchronized(this) {
if(!havePeer(pn)) return;
}
+ pn.notifyDisconnecting();
if(sendDisconnectMessage) {
Message msg = DMT.createFNPDisconnect(true, false, -1, new
ShortBuffer(new byte[0]));
try {
Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java 2007-09-20 22:00:22 UTC
(rev 15215)
+++ trunk/freenet/src/freenet/node/PeerNode.java 2007-09-20 22:12:14 UTC
(rev 15216)
@@ -299,6 +299,9 @@
* long time, but without preventing it from being GC'ed. */
final WeakReference myRef;
+ /** The node is being disconnected, but it may take a while. */
+ private boolean disconnecting;
+
private static boolean logMINOR;
/**
@@ -2324,6 +2327,8 @@
return "CLOCK PROBLEM";
if(status == PeerManager.PEER_NODE_STATUS_CONN_ERROR)
return "CONNECTION ERROR";
+ if(status == PeerManager.PEER_NODE_STATUS_DISCONNECTING)
+ return "DISCONNECTING";
return "UNKNOWN STATUS";
}
@@ -2355,11 +2360,15 @@
return "peer_listen_only";
if(status == PeerManager.PEER_NODE_STATUS_CLOCK_PROBLEM)
return "peer_clock_problem";
+ if(status == PeerManager.PEER_NODE_STATUS_DISCONNECTING)
+ return "peer_disconnecting";
return "peer_unknown_status";
}
protected synchronized int getPeerNodeStatus(long now, long
routingBackedOffUntil) {
checkConnectionsAndTrackers();
+ if(disconnecting)
+ return PeerManager.PEER_NODE_STATUS_DISCONNECTING;
if(isRoutable()) { // Function use also updates
timeLastConnected and timeLastRoutable
peerNodeStatus = PeerManager.PEER_NODE_STATUS_CONNECTED;
if(now < routingBackedOffUntil) {
@@ -2688,4 +2697,13 @@
/** Called when the peer is removed from the PeerManager */
public abstract void onRemove();
+
+ /** Called when a delayed disconnect is occurring. Tell the node that
it is being disconnected, but
+ * that the process may take a while. */
+ public void notifyDisconnecting() {
+ synchronized(this) {
+ disconnecting = true;
+ }
+ setPeerNodeStatus(System.currentTimeMillis());
+ }
}