Update of /cvsroot/freenet/freenet/src/freenet
In directory sc8-pr-cvs1:/tmp/cvs-serv11098/src/freenet
Modified Files:
ConnectionHandler.java OpenConnectionManager.java
PeerHandler.java
Log Message:
6231:
Allow clients to unregister themselves from maintenance process() in RSL. This fixes
some more FCP problems.
Prevent leak of TSL.dontReregister.
Bugfixes relating to SendData sending padding.
RSL.scheduleMaintenance takes a channel, not an NIOReader.
Cache Socket and SocketChannel on ConnectionHandler. Also changes the localport codes.
Logging
Index: ConnectionHandler.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/ConnectionHandler.java,v
retrieving revision 1.180
retrieving revision 1.181
diff -u -w -r1.180 -r1.181
--- ConnectionHandler.java 14 Oct 2003 00:43:14 -0000 1.180
+++ ConnectionHandler.java 14 Oct 2003 19:41:36 -0000 1.181
@@ -11,6 +11,7 @@
import freenet.transport.*;
import java.util.*;
import java.nio.*;
+import java.net.Socket;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SocketChannel;
import java.io.*;
@@ -115,6 +116,8 @@
ReceiveInputStream currentInputStream = null;
private PeerHandler peerHandler = null;
private boolean sendingCloseMessage = false;
+ private SocketChannel chan;
+ private Socket sock;
public long trailerLengthRemaining() {
if(sendClosed.state()) return 0;
@@ -279,6 +282,10 @@
}
}
conn = (tcpConnection)(link.getConnection());
+ sock = conn.getSocket();
+ if(sock == null)
+ throw new IOException("Already closed!");
+ chan = (SocketChannel)sock.getChannel();
if(logDEBUG) logDEBUG("Connection: "+conn);
if(conn == null) throw new IOException("Already closed!");
if(conn.isClosed()) throw new IOException("Already closed!");
@@ -444,15 +451,8 @@
}
public int getLocalPort() {
- tcpConnection c = conn;
- java.net.Socket sock;
- if (c == null) return -1;
- try {
- sock = conn.getSocket();
- } catch (IOException e) {
- return -2;
- }
- if(sock == null) return -3;
+ if(finalized.state()) return -4;
+ if(!chan.isOpen()) return -5;
return sock.getLocalPort();
}
@@ -491,7 +491,7 @@
disabledInSelector = false;
reregistering = true;
try {
- rsl.scheduleMaintenance(this);
+ rsl.scheduleMaintenance(chan);
} catch (Throwable e) {
Core.logger.log(this, "Cannot reregister "+this+", due to "+e,
e, Logger.ERROR);
terminate();
@@ -644,8 +644,7 @@
if(reregistering) {
logDEBUG("Completing reregistration");
try {
- rsl.register(conn.getSocket().getChannel(),
- this);
+ rsl.register(chan, this);
} catch (Throwable t) {
Core.logger.log(this, "Thrown "+t+
" reregistering
"+this,
@@ -656,7 +655,8 @@
reregistering = false;
}
}
- return innerProcess();
+ int x = innerProcess();
+ return x;
}
boolean closeNow = false;
@@ -890,7 +890,7 @@
if(trailerSendID == -1)
terminate();
return -1;
} else {
- if(logDEBUG) logDEBUG("Taking
off RSL, waiting for writes to finish");
+ if(logDEBUG) logDEBUG("Taking
off RSL, waiting for writes to finish", true);
return 0;
}
}
@@ -1178,8 +1178,8 @@
cm, true);
if(logDEBUG)
Core.logger.log(this,
"Sending "+sentPacket+
-
" ("+cm+") on "+this,
-
Logger.DEBUG);
+
" ("+cm+") on "+this+
+
" in jobDone", Logger.DEBUG);
} catch (IOException e) {
sentPacket = null;
logDEBUG("Caught "+e+
@@ -1634,7 +1634,7 @@
public void close() throws IOException{
if (dead) return;
innerClose();
-
rsl.queueClose(((tcpConnection)conn).getSocket().getChannel(),ConnectionHandler.this);
+ rsl.queueClose(chan, ConnectionHandler.this);
}
/**
@@ -1659,7 +1659,7 @@
if(rsl != null && a != null &&
(closeNow || (a.remaining() > 0))) {
logDEBUG("Scheduling maintenance");
- rsl.scheduleMaintenance(ConnectionHandler.this);
+ rsl.scheduleMaintenance(chan);
logDEBUG("Scheduled maintenance");
}
if(rsl == null) {
@@ -1984,12 +1984,8 @@
new Exception("debug"), Logger.DEBUG);
if(conn == null)
throw new IOException("Connection closed: "+this);
- java.net.Socket sock = conn.getSocket();
- if(sock == null)
- throw new IOException("Can't get socket");
- SelectableChannel chan = sock.getChannel();
- if(chan == null)
- throw new IOException("Can't get channel");
+ if(!chan.isOpen())
+ throw new IOException("Channel closed: "+this);
if(wsl == null)
throw new IllegalStateException("wsl null in "+
ConnectionHandler.this);
Index: OpenConnectionManager.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/OpenConnectionManager.java,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -w -r1.120 -r1.121
--- OpenConnectionManager.java 13 Oct 2003 15:42:00 -0000 1.120
+++ OpenConnectionManager.java 14 Oct 2003 19:41:37 -0000 1.121
@@ -1644,7 +1644,7 @@
// is now unregistered, it will not be checked
until we are
// registered
tcpConnection.getRSL().register(sock, ch);
- tcpConnection.getRSL().scheduleMaintenance(ch);
+
tcpConnection.getRSL().scheduleMaintenance(sock.getChannel());
if(logDEBUG) Core.logger.log(this, "Registered
"+this+":"+ch,
Logger.DEBUG);
//ch.run();
Index: PeerHandler.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/PeerHandler.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -w -r1.15 -r1.16
--- PeerHandler.java 11 Oct 2003 23:06:38 -0000 1.15
+++ PeerHandler.java 14 Oct 2003 19:41:37 -0000 1.16
@@ -338,7 +338,7 @@
// Can't open a connection
pm.notifyFailure(null);
if(logDEBUG)
- Core.logger.log(this, "Failed to send packet, no more
conns, no way to open connection: DISCARDING "+pm+" on "+this, Logger.NORMAL);
+ Core.logger.log(this, "Failed to send packet, no more
conns, no way to open connection: DISCARDING "+pm+" on "+this, id == null ?
Logger.NORMAL : Logger.MINOR); // id == null => FCP
return;
}
if(pm.priority == EXPENDABLE) {
_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs