Update of /cvsroot/freenet/freenet/src/freenet
In directory sc8-pr-cvs1:/tmp/cvs-serv24484/src/freenet
Modified Files:
ConnectionHandler.java
Log Message:
6191:
Correct counting of SendFinished's for RNFs - if it's a failure, it's unreachable, if
it's a timeout, it's "restarted".
Bugfixes to profiling counts of ConnectionHandler occurrences
Pool ConnectionHandler accumulators too to avoid expensive allocations and object churn
Include size of tcpConnection and ConnectionHandler buffer pools in interesting
objects dump
Logging
Index: ConnectionHandler.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/ConnectionHandler.java,v
retrieving revision 1.154
retrieving revision 1.155
diff -u -r1.154 -r1.155
--- ConnectionHandler.java 11 Sep 2003 01:17:15 -0000 1.154
+++ ConnectionHandler.java 11 Sep 2003 15:32:41 -0000 1.155
@@ -191,6 +191,15 @@
private volatile boolean trailingPresent=false;
private Object sendingQueueBytesLock = new Object();
private int sendingQueueBytes = 0;
+
+ private static LinkedList bufferPool = new LinkedList();
+
+ public static int bufferPoolSize() {
+ synchronized(bufferPool) {
+ return bufferPool.size();
+ }
+ }
+
// Constructors
/**
* The ConnectionHandler provides the interface between the session,
@@ -238,8 +247,15 @@
this.logDEBUG = Core.logger.shouldLog(Logger.DEBUG);
if(logDEBUG) logDEBUG("New connectionhandler with "+peer,
true);
- _accumulator = new byte[BUF_SIZE];
- accumulator = ByteBuffer.wrap(_accumulator);
+ synchronized(bufferPool) {
+ if(bufferPool.isEmpty()) {
+ _accumulator = new byte[BUF_SIZE];
+ accumulator = ByteBuffer.wrap(_accumulator);
+ } else {
+ accumulator =
(ByteBuffer)(bufferPool.removeFirst());
+ _accumulator = accumulator.array();
+ }
+ }
conn = (tcpConnection)(link.getConnection());
if(logDEBUG) logDEBUG("Connection: "+conn);
if(conn == null) throw new IOException("Already closed!");
@@ -252,11 +268,6 @@
link.setTimeout(600000); // 10 minutes
initRegisteredInOCM = false;
isFNP = link instanceof FnpLink ? true : false; //there may be
more elegant way
- //profiling
- //WARNING:remove before release
- synchronized(profLock) {
- instances++;
- }
} catch (IOException e) {
Core.logger.log(this, "IOException constructing "+this+": "+e+
"("+link+") for "+this, e,
Logger.MINOR);
@@ -273,6 +284,13 @@
Core.logger.log(this, "Got "+e+" in CH.<init> for "+this,
Logger.ERROR);
throw e;
+ } finally {
+ // Finalizer is called even if constructor throws
+ //profiling
+ //WARNING:remove before release
+ synchronized(profLock) {
+ instances++;
+ }
}
if(Node.obw != null)
this.maxPacketLength = Node.obw.maximumPacketLength();
@@ -2621,17 +2639,20 @@
// }
boolean wasClosed = alreadyClosedLink;
ByteBuffer a = accumulator;
- if(a != null)
+ if(a != null) {
synchronized(a) {
alreadyClosedLink = true;
a.notifyAll();
accumulator = null;
_accumulator = null;
}
+ synchronized(bufferPool) {
+ bufferPool.addLast(a);
+ }
+ }
try {
finalized.change();
- }
- catch (IrreversibleException e) {
+ } catch (IrreversibleException e) {
if(logDEBUG) logDEBUG("Already started terminating");
return;
// terminate called twice
@@ -2924,15 +2945,16 @@
Logger.ERROR);
terminate();
}
- //profiling
+
+ //profiling
//WARNING:remove before release
- synchronized(profLock) {
- instances--;
- }
+ synchronized(profLock) {
+ instances--;
+ }
}
-
-
-
+
+
+
//=========================================================================
// the rest is inner classes for streams that handle the trailing
// fields when sending/receiving messages
_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs