Update of /cvsroot/freenet/freenet/src/freenet
In directory sc8-pr-cvs1:/tmp/cvs-serv31561/src/freenet
Modified Files:
ConnectionHandler.java Message.java OpenConnectionManager.java
PeerHandler.java Version.java
Log Message:
6225:
Iakin:
* Logging fixes
* Fix a common, nasty NullPointerException introduced recently.
Me:
* Calculate total bytes queued in trailers, including what is sending and what is
queued, across all PeerHandlers. Use this for a reasonably accurate queue length in
OCM infolet.
- Message.trailerLength()
- PeerHandler.queuedBytes()
- OCM.totalSendQueueSize()
* Try to find error in ConnectionOpener causing stack track starting on Random.getInt
* Logging improvements.
Index: ConnectionHandler.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/ConnectionHandler.java,v
retrieving revision 1.169
retrieving revision 1.170
diff -u -r1.169 -r1.170
--- ConnectionHandler.java 8 Oct 2003 22:54:18 -0000 1.169
+++ ConnectionHandler.java 9 Oct 2003 00:23:38 -0000 1.170
@@ -115,6 +115,15 @@
private PeerHandler peerHandler = null;
private boolean sendingCloseMessage = false;
+ public long trailerLengthRemaining() {
+ if(sendClosed.state()) return 0;
+ synchronized(trailerSendLock) {
+ if(trailerSendID != -1) {
+ return trailerSendLength - trailerSentBytes;
+ } else return 0;
+ }
+ }
+
//private Thread exec_instance; // execution thread
private static EntropySource sendTimer = new EntropySource(),
recvTimer = new EntropySource();
Index: Message.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/Message.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Message.java 8 Oct 2003 22:54:18 -0000 1.7
+++ Message.java 9 Oct 2003 00:23:39 -0000 1.8
@@ -145,6 +145,8 @@
}
public abstract boolean hasTrailer();
+
+ public abstract long trailerLength();
}
Index: OpenConnectionManager.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/OpenConnectionManager.java,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -r1.118 -r1.119
--- OpenConnectionManager.java 9 Oct 2003 00:08:58 -0000 1.118
+++ OpenConnectionManager.java 9 Oct 2003 00:23:39 -0000 1.119
@@ -763,7 +763,24 @@
if (bytes>(2<<12)) return nf.format(bytes>>10) + " KiB";
return nf.format(bytes) + " Bytes";
}
-
+
+ /**
+ * Calculate the total length of the send queues on all the PeerHandlers.
+ * This takes both the connectionhandler and messages locks on each PH,
+ * so try to avoid calling it outside stuff like writeHtmlContents.
+ */
+ private long totalSendQueueSize() {
+ long total = 0;
+ synchronized(peerHandlers) {
+ for(Iterator i = peerHandlers.values().iterator();
+ i.hasNext();) {
+ PeerHandler ph = (PeerHandler)(i.next());
+ total += ph.queuedBytes();
+ }
+ }
+ return total;
+ }
+
/**
* Writes an HTML table with information about the open connections.
[EMAIL PROTECTED] pw A destination to write the HTML output
to
@@ -809,7 +826,7 @@
int outbound = 0;
int outboundNotInRoutingtable=0;
int inbound = 0;
- long sendQueueSize = 0;
+ long sendQueueSize = totalSendQueueSize();
long totalDataSent = 0;
long receiveQueueSize = 0;
long totalDataReceived = 0;
Index: PeerHandler.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/PeerHandler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PeerHandler.java 8 Oct 2003 22:54:18 -0000 1.7
+++ PeerHandler.java 9 Oct 2003 00:23:39 -0000 1.8
@@ -39,6 +39,26 @@
return super.toString() + " ("+id+","+ref+")";
}
+ public long queuedBytes() {
+ long queuedBytes = 0;
+ synchronized(messages) {
+ Iterator i = messagesWithTrailers.listIterator(0);
+ while(i.hasNext()) {
+ PeerPacketMessage ppm = (PeerPacketMessage)(i.next());
+ queuedBytes += ppm.trailerLength();
+ }
+ }
+ synchronized(connectionHandlers) {
+ Iterator i = connectionHandlers.listIterator(0);
+ while(i.hasNext()) {
+ ConnectionHandler ch = (ConnectionHandler)(i.next());
+ queuedBytes += ch.trailerLengthRemaining();
+ }
+ }
+ return queuedBytes;
+ // We can't find out the message length without resolving the messages
+ }
+
/**
* Register a ConnectionHandler to us. This should be called as soon as
* it has completed negotiations, not waiting for the Identify.
Index: Version.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/Version.java,v
retrieving revision 1.417
retrieving revision 1.418
diff -u -r1.417 -r1.418
--- Version.java 8 Oct 2003 22:54:18 -0000 1.417
+++ Version.java 9 Oct 2003 00:23:39 -0000 1.418
@@ -18,7 +18,7 @@
public static String protocolVersion = "1.46";
/** The build number of the current revision */
- public static final int buildNumber = 6224;
+ public static final int buildNumber = 6225;
// 6028: may 3; ARK retrieval fix
public static final int ignoreBuildsAfter = 6500;
_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs