Update of /cvsroot/freenet/freenet/src/freenet
In directory sc8-pr-cvs1:/tmp/cvs-serv13000/src/freenet
Modified Files:
ConnectionHandler.java OpenConnectionManager.java Version.java
Log Message:
6182:
* MAJOR bugfix in OpenConnectionManager, this may have been causing the connection
flooding bug.
* Add some consistency checking code to ConnectionHandler. Disabled currently.
* Remove flush() in SOS.done(), it doesn't do anything useful.
Index: ConnectionHandler.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/ConnectionHandler.java,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -r1.150 -r1.151
--- ConnectionHandler.java 8 Sep 2003 19:59:41 -0000 1.150
+++ ConnectionHandler.java 9 Sep 2003 00:15:53 -0000 1.151
@@ -70,7 +70,9 @@
/** Whether the ConnectionHandler has been started */
// private final Irreversible started = new Irreversible(false);
-
+
+ private static final boolean doCheckReallySending = false;
+
/** If no more messages will be read */
private final Irreversible receiveClosed = new Irreversible(false);
@@ -886,6 +888,54 @@
}
}
+ boolean checkingSending = false;
+ Object checkingSendingLock = new Object();
+
+ /**
+ * Check that we are in fact reallySending, and if the flag is incorrect,
+ * firstly, correct it, and secondly, log a big fat error message.
+ * Will get false positives if called within *sendMessage*, so don't
+ * use it in OpenConnectionManager.
+ */
+ public void checkReallySending() {
+ if(!doCheckReallySending) return;
+ synchronized(checkingSendingLock) {
+ if(checkingSending) return;
+ checkingSending = true;
+ }
+ try {
+ synchronized(sendLock) {
+ for(Iterator i = sentMessages.iterator();i.hasNext();)
{
+ MessageSend ms = (MessageSend)(i.next());
+ if(ms.hasTrailing) {
+ Core.logger.log(this, ms.toString()+
+ " on
sentMessages has trailing for "+
+ this,
Logger.DEBUG);
+ return;
+ }
+ }
+ for(Iterator i = sendingQueue.iterator();i.hasNext();)
{
+ MessageSend ms = (MessageSend)(i.next());
+ if(ms.hasTrailing) {
+ Core.logger.log(this, ms.toString()+
+ " on
sendingQueue has trailing for "+
+ this,
Logger.DEBUG);
+ return;
+ }
+ }
+ if(currentSOS != null) {
+ Core.logger.log(this, "We have a sender",
+ Logger.DEBUG);
+ return;
+ }
+ Core.logger.log(this, "TRAILING PRESENT FLAG INCORRECT
FOR "+this,
+ Logger.ERROR);
+ }
+ } finally {
+ checkingSending = false;
+ }
+ }
+
public void jobDone(int size, boolean status) {
if(logDEBUG)logDEBUG("CH.jobDone("+size+","+status+") for "+this+"
size of queue " +sendingQueue.size()+
" trailingPresent "+trailingPresent);
@@ -2256,6 +2306,8 @@
// needToRemoveFromOCM = false;
synchronized(sendLock) {
// Do not remove sendLock without seeing comments below
+ if(trailingPresent)
+ checkReallySending();
if (sendClosed.state())
// check again when synced
throw new
SendFailedException(peer.getAddress(), false);
@@ -3060,11 +3112,11 @@
public SendOutputStream(OutputStream out, long toWrite) {
super(out);
this.toWrite = toWrite;
- //profiling
- //WARNING:remove before release
- synchronized(profLockSOS) {
- SOSinstances++;
- }
+ //profiling
+ //WARNING:remove before release
+ synchronized(profLockSOS) {
+ SOSinstances++;
+ }
}
@@ -3124,14 +3176,6 @@
public void done() {
if (!done) {
done = true;
- try {
- out.flush();
- }
- catch (IOException e) {
- Core.logger.log(ConnectionHandler.this, "I/O error "+
- "when flushing
SendOutputStream: "+e,
- e, Logger.MINOR);
- }
synchronized (sendLock) {
--sendingCount;
@@ -3175,9 +3219,9 @@
Logger.ERROR);
done();
}
- synchronized(profLockSOS) {
- SOSinstances--;
- }
+ synchronized(profLockSOS) {
+ SOSinstances--;
+ }
super.finalize();
}
}
Index: OpenConnectionManager.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/OpenConnectionManager.java,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -r1.98 -r1.99
--- OpenConnectionManager.java 8 Sep 2003 19:59:41 -0000 1.98
+++ OpenConnectionManager.java 9 Sep 2003 00:15:53 -0000 1.99
@@ -188,10 +188,10 @@
} else {
if(!res.reallySending()){
candidates.add(res);
- }
- else if (logDebug)
+ } else if (logDebug) {
Core.logger.log(this, "Skipping:
"+res+": sending",
- Logger.DEBUG);
+
Logger.DEBUG);
+ }
}
}
}
@@ -348,10 +348,15 @@
synchronized (ct) {
if(timeout == -1 && !ct.done) {
+ Core.logger.log(this, "Starting "+ct+
+ " on thread",
Logger.DEBUG);
ct.run();
} else {
- if(weStarted)
+ if(weStarted) {
+ Core.logger.log(this, "Starting "+ct+
+ " on
thread", Logger.DEBUG);
tf.getThread(ct);
+ }
//tm.forceRun(ct);
// Restored pooled threads (oskar 20020204)
//Thread job = new Thread(ct,
@@ -365,7 +370,7 @@
while (!ct.done) {
try {
- if (timeout < 0) {
+ if (timeout <= 0) {
ct.wait(5*60*1000);
} else {
long wait = endtime -
System.currentTimeMillis();
@@ -383,9 +388,8 @@
Core.diagnostics.occurrenceBinomial("connectionRatio",1,0);
if (timeout <= 0) {
Core.logger.log(this, "Something is
very wrong new " +
-
"connections for "+p+" ("+ct+
- ").
Waited 5 minutes"+
- "
("+timeout+")", Logger.ERROR);
+
"connections for "+p+" ("+ct+"). Timeout was "+
+
timeout+")", Logger.ERROR);
}
ConnectFailedException e =
new
ConnectFailedException(p.getAddress(),
Index: Version.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/Version.java,v
retrieving revision 1.374
retrieving revision 1.375
diff -u -r1.374 -r1.375
--- Version.java 8 Sep 2003 19:59:41 -0000 1.374
+++ Version.java 9 Sep 2003 00:15:53 -0000 1.375
@@ -18,7 +18,7 @@
public static String protocolVersion = "1.46";
/** The build number of the current revision */
- public static final int buildNumber = 6181;
+ public static final int buildNumber = 6182;
// 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