Update of /cvsroot/freenet/freenet/src/freenet/node
In directory sc8-pr-cvs1:/tmp/cvs-serv1809/src/freenet/node
Modified Files:
Node.java ConnectionOpener.java Main.java
Log Message:
6506: Fix the NPE by keeping a default Presentation for stats purposes, don't log FCP
Messages in PH stats
Index: Node.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/Node.java,v
retrieving revision 1.239
retrieving revision 1.240
diff -u -w -r1.239 -r1.240
--- Node.java 1 Nov 2003 22:05:36 -0000 1.239
+++ Node.java 4 Nov 2003 16:53:23 -0000 1.240
@@ -2353,14 +2353,15 @@
* @param ph The presentationHandler to use for making connections
* @param loadStats The restored LoadStats object
* @param isTransient whether this node is transient
+ * @param defaultPresentation The default Presentation for stats purposes
*/
public Node(Authentity privKey, NodeReference myRef,
Directory dir, BucketFactory bf, DataStore ds, RoutingTable rt,
FailureTable ft, TransportHandler th, SessionHandler sh,
- PresentationHandler ph, LoadStats loadStats,
- boolean isTransient) {
+ PresentationHandler ph, Presentation defaultPresentation,
+ LoadStats loadStats, boolean isTransient) {
- super(privKey, myRef.getIdentity(), th, sh, ph);
+ super(privKey, myRef.getIdentity(), th, sh, ph, defaultPresentation);
this.myRef = myRef;
this.dir = dir;
this.bf = bf;
@@ -2887,13 +2888,14 @@
long timeout)
throws CommunicationException {
return connections.sendMessage(m, nr.getIdentity(), nr, timeout,
- PeerHandler.NORMAL);
+ PeerHandler.NORMAL, defaultPresentation);
}
public final TrailerWriter sendMessage(Message m, Peer p, long timeout,
int msgPrio)
throws CommunicationException {
- return connections.sendMessage(m, p.getIdentity(), null, timeout, msgPrio);
+ return connections.sendMessage(m, p.getIdentity(), null, timeout, msgPrio,
+ defaultPresentation);
}
/**
@@ -2911,14 +2913,14 @@
MessageSendCallback cb)
throws CommunicationException {
connections.sendMessageAsync(m, p.getIdentity(), null, cb, timeout,
- msgPrio);
+ msgPrio, defaultPresentation);
}
public final void sendMessageAsync(Message m, Peer p, long timeout,
MessageSendCallback cb)
throws CommunicationException {
connections.sendMessageAsync(m, p.getIdentity(), null, cb,
- timeout, PeerHandler.NORMAL);
+ timeout, PeerHandler.NORMAL,
defaultPresentation);
}
public final void sendMessageAsync(Message m, NodeReference nr,
@@ -2926,7 +2928,8 @@
MessageSendCallback cb)
throws CommunicationException {
connections.sendMessageAsync(m, nr.getIdentity(), nr, cb,
- timeout, PeerHandler.NORMAL);
+ timeout, PeerHandler.NORMAL,
+ defaultPresentation);
}
public final void sendMessageAsync(Message m, NodeReference nr,
@@ -2934,7 +2937,7 @@
MessageSendCallback cb)
throws CommunicationException {
connections.sendMessageAsync(m, nr.getIdentity(), nr, cb,
- timeout, prio);
+ timeout, prio, defaultPresentation);
}
public final void unsendMessage(Identity i, MessageSendCallback cb) {
@@ -3021,13 +3024,13 @@
*/
public void scheduleConnectionOpener(Identity id) {
if(id == null) throw new IllegalArgumentException("null identity");
- ConnectionOpener.scheduleConnectionOpener(id, this, false);
+ ConnectionOpener.scheduleConnectionOpener(id, this, false,
defaultPresentation);
}
public void scheduleConnectionBackoff(Identity id) {
if(id == null) throw new IllegalArgumentException("null identity");
NodeReference ref = rt.getNodeReference(id);
- ConnectionOpener.scheduleConnectionOpener(id, this, true);
+ ConnectionOpener.scheduleConnectionOpener(id, this, true,
defaultPresentation);
}
/**
@@ -3038,8 +3041,8 @@
public void reference(Key k, NodeReference nr) {
rt.reference(k, nr);
Identity id = nr.getIdentity();
- connections.addPeer(id, nr);
- ConnectionOpener.scheduleConnectionOpener(id, this, true);
+ connections.addPeer(id, nr, defaultPresentation);
+ ConnectionOpener.scheduleConnectionOpener(id, this, true,
defaultPresentation);
}
/**
@@ -3058,10 +3061,12 @@
Identity id = ref.getIdentity();
if(connections.getPeerHandler(id) == null) {
PeerHandler ph = new PeerHandler(id, ref, this,
- getMaxPacketLength());
+ getMaxPacketLength(),
+ defaultPresentation); // FNP
connections.addPeerHandler(id, ph, true);
}
- ConnectionOpener.scheduleConnectionOpener(id, this, true);
+ ConnectionOpener.scheduleConnectionOpener(id, this, true,
+ defaultPresentation);
}
Core.logger.log(this, "Scheduled open on all connections",
Logger.MINOR);
Index: ConnectionOpener.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/ConnectionOpener.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -w -r1.26 -r1.27
--- ConnectionOpener.java 31 Oct 2003 21:09:11 -0000 1.26
+++ ConnectionOpener.java 4 Nov 2003 16:53:25 -0000 1.27
@@ -2,6 +2,7 @@
import freenet.ConnectionHandler;
import freenet.Identity;
import freenet.OpenConnectionManager;
+import freenet.Presentation;
import freenet.node.rt.RoutingTable;
import freenet.node.Node;
import freenet.node.states.maintenance.Checkpoint;
@@ -18,6 +19,7 @@
protected final Node node;
protected final Identity id;
protected final OpenConnectionManager ocm;
+ protected final Presentation p;
int currentDelay = 0;
int baseBackoffDelay = 0;
int startBackoffDelay=1000;
@@ -36,10 +38,11 @@
* node.
* @param aaargh if true, schedule a post-connection backoff,
* because something broke immediately after connection.
+ * @param p the default Presentation, used for PeerHandler stats.
*/
public static void scheduleConnectionOpener(Identity id,
Node n,
- boolean aaargh) {
+ boolean aaargh, Presentation p) {
boolean logDEBUG =
Node.logger.shouldLog(Logger.DEBUG,ConnectionOpener.class);
if(logDEBUG)
@@ -56,7 +59,7 @@
synchronized(connOpeners) {
ConnectionOpener co = (ConnectionOpener)(connOpeners.get(id));
if(co == null) {
- co = new ConnectionOpener(id, n);
+ co = new ConnectionOpener(id, n, p);
//connOpeners.put(id, co); //Done by reschedule below
if(logDEBUG)
Core.logger.log(co, "Created "+co+" for "+id,Logger.DEBUG);
@@ -65,8 +68,9 @@
}
}
- public ConnectionOpener(Identity id, Node node) {
+ public ConnectionOpener(Identity id, Node node, Presentation p) {
this.rt = node.rt;
+ this.p = p;
this.node = node;
this.id = id;
this.ocm = node.connections;
@@ -160,7 +164,7 @@
backoff();
return;
}
- PeerHandler ph = ocm.makePeerHandler(id, null);
+ PeerHandler ph = ocm.makePeerHandler(id, null, p);
if(ph == null) {
Core.logger.log(this, "ocm returned null for peerhandler for "+
id, Logger.ERROR);
Index: Main.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/Main.java,v
retrieving revision 1.291
retrieving revision 1.292
diff -u -w -r1.291 -r1.292
--- Main.java 4 Nov 2003 01:24:25 -0000 1.291
+++ Main.java 4 Nov 2003 16:53:25 -0000 1.292
@@ -42,6 +42,7 @@
import freenet.ListeningAddress;
import freenet.MessageHandler;
import freenet.OpenConnectionManager;
+import freenet.Presentation;
import freenet.PresentationHandler;
import freenet.SessionHandler;
import freenet.Ticker;
@@ -529,7 +530,8 @@
th.register(new TCP(100, strictAddresses));
FNPmgr = new FnpLinkManager(negotiationLimit);
sh.register(FNPmgr, 100);
- ph.register(new FreenetProtocol(), 100);
+ Presentation defaultPresentation = new FreenetProtocol();
+ ph.register(defaultPresentation, 100);
int ipDetectorInterval = params.getInt("ipDetectorInterval");
if(ipDetectorInterval > 0)
@@ -970,7 +972,7 @@
Logger.NORMAL);
node = new Node(privateKey, myRef, dir, bf, ds, rt,
- ft, th, sh, ph, loadStats,
+ ft, th, sh, ph, defaultPresentation, loadStats,
isTransient);
if(origRT instanceof StoredRoutingTable)
((StoredRoutingTable)origRT).setNode(node);
_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs