Update of /cvsroot/freenet/freenet/src/freenet/interfaces
In directory sc8-pr-cvs1:/tmp/cvs-serv2307/src/freenet/interfaces
Modified Files:
LocalHTTPInterface.java LocalNIOInterface.java
Log Message:
6171:
Add ConnectionHandler.useValue(). Use it to queue messages to the least congested
connection if we can't get a non-sending() connection. Prevents a nasty feedback
situation. Also tweak the 2 connections logic - it's 2 *message* connections, not 2
connections full stop.
Process queued connections immediately on going below lowRunningConnections, don't
wait for the next incoming connection.
Update LocalHTTPInterface a bit (not actually used, just for testing new HTTP
infrastructure).
Logging, indenting.
Index: LocalHTTPInterface.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/interfaces/LocalHTTPInterface.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- LocalHTTPInterface.java 5 Aug 2003 18:08:56 -0000 1.6
+++ LocalHTTPInterface.java 5 Sep 2003 03:32:43 -0000 1.7
@@ -30,14 +30,10 @@
public class LocalHTTPInterface extends BaseLocalNIOInterface {
- public final ReadSelectorLoop rsl;
- public final WriteSelectorLoop wsl;
public final MultipleHttpServletContainer container;
public final SessionHolder sh = new SessionHolderImpl();
public LocalHTTPInterface(ListeningAddress listenAddr,
- ReadSelectorLoop rsl,
- WriteSelectorLoop wsl,
MultipleHttpServletContainer
container,
String allowedHosts,
int lowRunningConnections,
@@ -45,8 +41,6 @@
throws ListenException {
super(listenAddr, allowedHosts, lowRunningConnections,
highRunningConnections);
- this.rsl = rsl;
- this.wsl = wsl;
this.container = container;
}
@@ -71,7 +65,7 @@
SocketChannel sc = sock.getChannel();
Core.logger.log(this, "Got channel: "+sc, Logger.DEBUG);
HTTPCallback hc = new HTTPCallback(sc, conn);
- hc.configWSL(wsl);
+ hc.configWSL(tcpConnection.getWSL());
niois.setNextReader(hc);
tcpConnection.getRSL().unregister(niois);
Core.logger.log(this, "Almost registered channel", Logger.DEBUG);
@@ -220,6 +214,7 @@
Core.logger.log(this, "Sending packet of length "+buf.length,
Logger.DEBUG);
try {
+ WriteSelectorLoop wsl = tcpConnection.getWSL();
if(!wsl.send(buf, sc, this,wsl.MESSAGE)) {
Core.logger.log(this, "Failed send",
Logger.DEBUG);
sending.add(buf);
@@ -241,6 +236,7 @@
if(sending.size() > 0) {
byte[] buf = (byte[])(sending.remove(0));
try {
+ WriteSelectorLoop wsl =
tcpConnection.getWSL();
if(!wsl.send(buf, sc,
this,wsl.MESSAGE)) {
Core.logger.log(this, "Could
not send data in jobDone handler!", Logger.ERROR);
}
Core.logger.log(this, "Sent some data in jobDone",
@@ -250,7 +246,7 @@
Logger.ERROR);
}
} else if (closeAfterSent) {
- rsl.queueClose(sc);
+ tcpConnection.getRSL().queueClose(sc);
// WriteSelectorLoop doesn't know about it
unless we are actually sending data
}
}
Index: LocalNIOInterface.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/interfaces/LocalNIOInterface.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- LocalNIOInterface.java 5 Sep 2003 02:00:46 -0000 1.4
+++ LocalNIOInterface.java 5 Sep 2003 03:32:43 -0000 1.5
@@ -151,7 +151,8 @@
if(logDEBUG)
Core.logger.log(this, "Accepting connection immediately: "+
conn, Logger.DEBUG);
- realHandleConnection(conn);
+ if(conn != null)
+ realHandleConnection(conn);
synchronized(oldConnections) {
int i=0;
while(!oldConnections.isEmpty() && acceptingConnections) {
@@ -175,7 +176,8 @@
if(deleted > 0)
Core.logger.log(this, "Dropped "+deleted+" old connections",
Logger.NORMAL);
- oldConnections.addFirst(conn);
+ if(conn != null)
+ oldConnections.addFirst(conn);
if(logDEBUG)
Core.logger.log(this, "Added "+conn+" - "+oldConnections.size()+
" connections queued", Logger.DEBUG);
@@ -246,22 +248,7 @@
}
protected void finalize() {
- synchronized(LocalNIOInterface.this) {
- if(uppedRC == true) {
- runningConnections--;
- uppedRC = false;
- if(runningConnections < lowRunningConnections
- && !acceptingConnections) {
- Core.logger.log(this, "Restarting processing connections "+
- this, Logger.MINOR);
- acceptingConnections = true;
- }
- if(logDEBUG)
- Core.logger.log(this, "RunningConnections now "+
- runningConnections+", listening = "+
- isListening(), Core.logger.DEBUG);
- }
- }
+ decrementRunningConnections();
}
/** Main processing method for the ConnectionShell object */
@@ -282,21 +269,28 @@
e.printStackTrace(Core.logStream);
conn.close();
} finally {
- synchronized(LocalNIOInterface.this) {
+ decrementRunningConnections();
+ }
+ }
+
+ protected void decrementRunningConnections() {
+ synchronized(LocalNIOInterface.this) {
+ if(uppedRC == true) {
runningConnections--;
uppedRC = false;
- }
- if(runningConnections < lowRunningConnections
- && !acceptingConnections) {
- Core.logger.log(this, "Restarting processing connections "+
- this, Logger.MINOR);
- acceptingConnections = true;
- }
- if(logDEBUG)
- Core.logger.log(this, "RunningConnections now "+
- runningConnections+", listening = "+
- isListening(), Core.logger.DEBUG);
+ if(logDEBUG)
+ Core.logger.log(this, "RunningConnections now "+
+ runningConnections+", listening = "+
+ isListening(), Core.logger.DEBUG);
+ if(runningConnections < lowRunningConnections
+ && !acceptingConnections) {
+ Core.logger.log(this, "Restarting processing connections "+
+ this, Logger.MINOR);
+ acceptingConnections = true;
+ } else return;
+ } else return;
}
- }
+ handleConnection(null);
+ }
}
}
_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs