Author: toad
Date: 2008-11-06 19:59:16 +0000 (Thu, 06 Nov 2008)
New Revision: 23364
Modified:
trunk/freenet/src/freenet/node/IPDetectorPluginManager.java
trunk/freenet/src/freenet/node/NodeClientCore.java
trunk/freenet/src/freenet/node/NodeIPDetector.java
trunk/freenet/src/freenet/pluginmanager/PluginHandler.java
Log:
Don't start the IP detector plugin manager until the plugins have been loaded.
For threadless plugins, start them and register them during startup.
Modified: trunk/freenet/src/freenet/node/IPDetectorPluginManager.java
===================================================================
--- trunk/freenet/src/freenet/node/IPDetectorPluginManager.java 2008-11-06
19:55:40 UTC (rev 23363)
+++ trunk/freenet/src/freenet/node/IPDetectorPluginManager.java 2008-11-06
19:59:16 UTC (rev 23364)
@@ -834,6 +834,7 @@
} finally {
synchronized(IPDetectorPluginManager.this) {
runners.remove(plugin);
+ if(!runners.isEmpty()) return;
}
detector.hasDetectedPM();
}
Modified: trunk/freenet/src/freenet/node/NodeClientCore.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeClientCore.java 2008-11-06 19:55:40 UTC
(rev 23363)
+++ trunk/freenet/src/freenet/node/NodeClientCore.java 2008-11-06 19:59:16 UTC
(rev 23364)
@@ -507,6 +507,7 @@
fcpServer.finishStart();
persistentTempBucketFactory.completedInit();
node.pluginManager.start(node.config);
+ node.ipDetector.ipDetectorManager.start();
// FIXME most of the work is done after this
point on splitfile starter threads.
// So do we want to make a fuss?
// FIXME but a better solution is real request
resuming.
Modified: trunk/freenet/src/freenet/node/NodeIPDetector.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeIPDetector.java 2008-11-06 19:55:40 UTC
(rev 23363)
+++ trunk/freenet/src/freenet/node/NodeIPDetector.java 2008-11-06 19:59:16 UTC
(rev 23364)
@@ -481,7 +481,6 @@
if(!haveValidAddressOverride) {
onNotGetValidAddressOverride();
}
- ipDetectorManager.start();
node.executor.execute(ipDetector, "IP address re-detector");
redetectAddress();
// 60 second delay for inserting ARK to avoid reinserting more
than necessary if we don't detect IP on startup.
@@ -515,6 +514,8 @@
}
void hasDetectedPM() {
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "hasDetectedPM() called", new
Exception("debug"));
synchronized(this) {
hasDetectedPM = true;
}
Modified: trunk/freenet/src/freenet/pluginmanager/PluginHandler.java
===================================================================
--- trunk/freenet/src/freenet/pluginmanager/PluginHandler.java 2008-11-06
19:55:40 UTC (rev 23363)
+++ trunk/freenet/src/freenet/pluginmanager/PluginHandler.java 2008-11-06
19:59:16 UTC (rev 23364)
@@ -34,11 +34,12 @@
t.start();
}
};
+ pm.getTicker().queueTimedJob(job, 0);
} else {
- job = ps;
+ // Avoid NPEs: let it init, then register it.
+ plug.runPlugin(pr);
+ pm.register(plug, pi);
}
- // Run immediately after startup
- pm.getTicker().queueTimedJob(job, 0);
return pi;
}
@@ -59,13 +60,9 @@
}
public void run() {
- boolean threadless = plugin instanceof
FredPluginThreadless;
try {
- if(!threadless) // Have to do it now
because threaded
- pm.register(plugin, pi);
+ pm.register(plugin, pi);
plugin.runPlugin(pr);
- if(threadless) // Don't want it to
receive callbacks until after it has the PluginRespirator, else get NPEs
- pm.register(plugin, pi);
} catch (OutOfMemoryError e) {
OOMHandler.handleOOM(e);
} catch (Throwable t) {
@@ -73,10 +70,8 @@
System.err.println("Caught Throwable
while running plugin: "+t);
t.printStackTrace();
}
- if(!threadless) {
- pi.unregister(pm); // If not already
unregistered
- pm.removePlugin(pi);
- }
+ pi.unregister(pm); // If not already
unregistered
+ pm.removePlugin(pi);
}
}