Author: toad
Date: 2008-01-18 14:51:15 +0000 (Fri, 18 Jan 2008)
New Revision: 17140
Added:
trunk/freenet/src/freenet/clients/http/StartupToadlet.java
Removed:
trunk/freenet/src/freenet/clients/http/StartupToadletServer.java
Modified:
trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
trunk/freenet/src/freenet/clients/http/StaticToadlet.java
trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
trunk/freenet/src/freenet/node/Node.java
trunk/freenet/src/freenet/node/NodeClientCore.java
Log:
Use SimpleToadletServer during startup, not two different servers, one of which
has to be killed and therefore frequently causes bind failures.
Initially it only has the static toadlet and the startup toadlet, we add the
others later on.
Modified: trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyToadlet.java 2008-01-18
14:41:31 UTC (rev 17139)
+++ trunk/freenet/src/freenet/clients/http/FProxyToadlet.java 2008-01-18
14:51:15 UTC (rev 17140)
@@ -595,16 +595,10 @@
return f;
}
- public static SimpleToadletServer maybeCreateFProxyEtc(NodeClientCore
core, Node node, Config config, SubConfig fproxyConfig) throws IOException,
InvalidConfigValueException {
+ public static SimpleToadletServer maybeCreateFProxyEtc(NodeClientCore
core, Node node, Config config, SubConfig fproxyConfig, SimpleToadletServer
server) throws IOException, InvalidConfigValueException {
- SimpleToadletServer server = null;
-
// FIXME how to change these on the fly when the interface
language is changed?
- try {
-
- server = new SimpleToadletServer(fproxyConfig, core);
-
HighLevelSimpleClient client =
core.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS, true);
random = new byte[32];
@@ -625,9 +619,6 @@
ConfigToadlet configtoadlet = new ConfigToadlet(client,
config, node, core);
server.register(configtoadlet, "/config/", true,
"FProxyToadlet.configTitle", "FProxyToadlet.config", true, null);
- StaticToadlet statictoadlet = new StaticToadlet(client);
- server.register(statictoadlet, "/static/", true, false);
-
SymlinkerToadlet symlinkToadlet = new
SymlinkerToadlet(client, node);
server.register(symlinkToadlet, "/sl/", true, false);
@@ -666,13 +657,6 @@
FirstTimeWizardToadlet firstTimeWizardToadlet = new
FirstTimeWizardToadlet(client, node, core);
server.register(firstTimeWizardToadlet,
FirstTimeWizardToadlet.TOADLET_URL, true, false);
- }catch (BindException e){
- Logger.error(core,"Failed to start FProxy port already
bound: isn't Freenet already running ?", e);
- System.err.println("Failed to start FProxy port already
bound: isn't Freenet already running ?");
- throw new
InvalidConfigValueException(l10n("cantBindPort"));
- }catch (IOException ioe) {
- Logger.error(core,"Failed to start FProxy: "+ioe, ioe);
- }
fproxyConfig.finishedInitialization();
Modified: trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
2008-01-18 14:41:31 UTC (rev 17139)
+++ trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
2008-01-18 14:51:15 UTC (rev 17140)
@@ -31,6 +31,7 @@
import freenet.io.SSLNetworkInterface;
import freenet.l10n.L10n;
import freenet.node.NodeClientCore;
+import freenet.support.Executor;
import freenet.support.HTMLNode;
import freenet.support.Logger;
import freenet.support.OOMHandler;
@@ -55,7 +56,7 @@
String bindTo;
private String allowedHosts;
final AllowedHosts allowedFullAccess;
- final BucketFactory bf;
+ BucketFactory bf;
NetworkInterface networkInterface;
private final LinkedList toadlets;
private String cssName;
@@ -65,7 +66,8 @@
private boolean ssl = false;
private boolean fProxyJavascriptEnabled;
private final PageMaker pageMaker;
- private final NodeClientCore core;
+ private NodeClientCore core;
+ private final Executor executor;
private boolean doRobots;
static boolean isPanicButtonToBeShown;
@@ -163,6 +165,7 @@
}
public void set(String val) throws InvalidConfigValueException {
+ if(core == null) return;
if(val.equals(get()) || val.equals(""))
cssOverride = null;
else {
@@ -237,13 +240,18 @@
}
}
+ public synchronized void setCore(NodeClientCore core) {
+ this.core = core;
+ }
+
/**
* Create a SimpleToadletServer, using the settings from the SubConfig
(the fproxy.*
* config).
*/
- public SimpleToadletServer(SubConfig fproxyConfig, NodeClientCore core)
throws IOException, InvalidConfigValueException {
+ public SimpleToadletServer(SubConfig fproxyConfig, BucketFactory
bucketFactory, Executor executor) throws IOException,
InvalidConfigValueException {
- this.core = core;
+ this.executor = executor;
+
int configItemOrder = 0;
fproxyConfig.register("enabled", true, configItemOrder++, true,
true, "SimpleToadletServer.enabled", "SimpleToadletServer.enabledLong",
@@ -344,7 +352,7 @@
doRobots = fproxyConfig.getBoolean("doRobots");
SimpleToadletServer.isPanicButtonToBeShown =
fproxyConfig.getBoolean("showPanicButton");
- this.bf = core.tempBucketFactory;
+ this.bf = bucketFactory;
port = fproxyConfig.getInt("port");
bindTo = fproxyConfig.getString("bindTo");
cssName = fproxyConfig.getString("css");
@@ -368,21 +376,37 @@
this.allowedHosts=fproxyConfig.getString("allowedHosts");
if(!enabled) {
- Logger.normal(core, "Not starting FProxy as it's
disabled");
+ Logger.normal(SimpleToadletServer.this, "Not starting
FProxy as it's disabled");
System.out.println("Not starting FProxy as it's
disabled");
} else {
maybeGetNetworkInterface();
myThread = new Thread(this, "SimpleToadletServer");
myThread.setDaemon(true);
}
+
+ // Register static toadlet and startup toadlet
+
+ StaticToadlet statictoadlet = new StaticToadlet();
+ register(statictoadlet, "/static/", true, false);
+
+ startupToadlet = new StartupToadlet(statictoadlet);
+ register(startupToadlet, "/", true, false);
+
}
+ private StartupToadlet startupToadlet;
+
+ public void removeStartupToadlet() {
+ toadlets.remove(startupToadlet);
+ // Not in the navbar.
+ }
+
private void maybeGetNetworkInterface() throws IOException {
if (this.networkInterface!=null) return;
if(ssl) {
- this.networkInterface =
SSLNetworkInterface.create(port, this.bindTo, allowedHosts, core.getExecutor(),
true);
+ this.networkInterface =
SSLNetworkInterface.create(port, this.bindTo, allowedHosts, executor, true);
} else {
- this.networkInterface = NetworkInterface.create(port,
this.bindTo, allowedHosts, core.getExecutor(), true);
+ this.networkInterface = NetworkInterface.create(port,
this.bindTo, allowedHosts, executor, true);
}
}
@@ -415,6 +439,10 @@
}
}
+ public void unregister(Toadlet t) {
+
+ }
+
public Toadlet findToadlet(URI uri) {
Iterator i = toadlets.iterator();
while(i.hasNext()) {
@@ -457,7 +485,7 @@
}
void start() {
- core.getExecutor().execute(this, "HTTP socket
handler@"+hashCode());
+ executor.execute(this, "HTTP socket
handler@"+hashCode());
}
public void run() {
@@ -465,7 +493,11 @@
boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(logMINOR) Logger.minor(this, "Handling connection");
try {
- ToadletContextImpl.handle(sock,
SimpleToadletServer.this, bf, pageMaker);
+ NodeClientCore c;
+ synchronized(SimpleToadletServer.this) {
+ c = core;
+ }
+ ToadletContextImpl.handle(sock,
SimpleToadletServer.this, bf, pageMaker, c != null);
} catch (OutOfMemoryError e) {
OOMHandler.handleOOM(e);
System.err.println("SimpleToadletServer request
above failed.");
@@ -504,6 +536,7 @@
}
public String getFormPassword() {
+ if(core == null) return "";
return core.formPassword;
}
@@ -529,4 +562,8 @@
return formNode;
}
+ public void setBucketFactory(BucketFactory tempBucketFactory) {
+ this.bf = tempBucketFactory;
+ }
+
}
Added: trunk/freenet/src/freenet/clients/http/StartupToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StartupToadlet.java
(rev 0)
+++ trunk/freenet/src/freenet/clients/http/StartupToadlet.java 2008-01-18
14:51:15 UTC (rev 17140)
@@ -0,0 +1,47 @@
+/**
+ *
+ */
+package freenet.clients.http;
+
+import java.io.IOException;
+import java.net.URI;
+
+import freenet.support.HTMLNode;
+import freenet.support.api.HTTPRequest;
+
+class StartupToadlet extends Toadlet {
+
+ private StaticToadlet staticToadlet;
+
+ public StartupToadlet(StaticToadlet staticToadlet) {
+ super(null);
+ }
+
+ public void handleGet(URI uri, HTTPRequest req, ToadletContext ctx) throws
ToadletContextClosedException, IOException, RedirectException {
+ // If we don't disconnect we will have pipelining issues
+ ctx.forceDisconnect();
+
+ String path = uri.getPath();
+ if(path.startsWith(StaticToadlet.ROOT_URL)) {
+ staticToadlet.handleGet(uri, req, ctx);
+ } else {
+ String desc = "Freenet is starting up";
+ HTMLNode pageNode = ctx.getPageMaker().getPageNode(desc, false,
ctx);
+ HTMLNode headNode = ctx.getPageMaker().getHeadNode(pageNode);
+ headNode.addChild("meta", new String[]{"http-equiv", "content"},
new String[]{"refresh", "20; url="});
+ HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode);
+
+ HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-error", desc));
+ HTMLNode infoboxContent = ctx.getPageMaker().getContentNode(infobox);
+ infoboxContent.addChild("#", "Your freenet node is starting up, please
hold on.");
+
+ WelcomeToadlet.maybeDisplayWrapperLogfile(ctx, contentNode);
+ //TODO: send a Retry-After header ?
+ writeHTMLReply(ctx, 503, desc, pageNode.generate());
+ }
+}
+
+ public String supportedMethods() {
+ return "GET";
+ }
+}
\ No newline at end of file
Deleted: trunk/freenet/src/freenet/clients/http/StartupToadletServer.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StartupToadletServer.java
2008-01-18 14:41:31 UTC (rev 17139)
+++ trunk/freenet/src/freenet/clients/http/StartupToadletServer.java
2008-01-18 14:51:15 UTC (rev 17140)
@@ -1,231 +0,0 @@
-/* This code is part of Freenet. It is distributed under the GNU General
- * Public License, version 2 (or at your option any later version). See
- * http://www.gnu.org/ for further details of the GPL. */
-package freenet.clients.http;
-
-import freenet.support.HTMLNode;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
-import java.net.URI;
-import freenet.io.NetworkInterface;
-import freenet.l10n.L10n;
-import freenet.support.Logger;
-import freenet.support.OOMHandler;
-import freenet.support.SimpleFieldSet;
-import freenet.support.Executor;
-import freenet.support.api.BucketFactory;
-import freenet.support.api.HTTPRequest;
-import freenet.support.io.ArrayBucketFactory;
-
-/**
- * A Placeholder displayed before fproxy starts up.
- *
- * @author nextgens
- *
- * TODO: Maybe add a progress bar or something ?
- * TODO: What about userAlerts ?
- * TODO: Shall l10n be loaded before ?
- */
-public class StartupToadletServer implements Runnable {
-
- private int port;
- private String bindTo, allowedHosts;
- private final NetworkInterface networkInterface;
- private String cssName;
- private Thread myThread;
- private final PageMaker pageMaker;
- private String formPassword;
- private Executor executor;
- private final BucketFactory bf = new ArrayBucketFactory();
- private final ToadletContainer container = new ToadletContainer() {
-
- public void register(Toadlet t, String urlPrefix, boolean atFront,
boolean fullAccessOnly) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
- public Toadlet findToadlet(URI uri) {
- return startupToadlet;
- }
-
- public String getCSSName() {
- return cssName;
- }
-
- public String getFormPassword() {
- return formPassword;
- }
-
- public boolean isAllowedFullAccess(InetAddress remoteAddr) {
- return false;
- }
-
- public boolean doRobots() {
- return true;
- }
-
- public HTMLNode addFormChild(HTMLNode parentNode, String target,
String name) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- };
-
- private final Toadlet startupToadlet = new Toadlet(null) {
- public void handleGet(URI uri, HTTPRequest req, ToadletContext ctx)
throws ToadletContextClosedException, IOException, RedirectException {
- // If we don't disconnect we will have pipelining issues
- ctx.forceDisconnect();
-
- String path = uri.getPath();
- if(path.startsWith(StaticToadlet.ROOT_URL)) {
- staticToadlet.handleGet(uri, req, ctx);
- } else {
- String desc = "Freenet is starting up";
- HTMLNode pageNode = ctx.getPageMaker().getPageNode(desc,
false, ctx);
- HTMLNode headNode = ctx.getPageMaker().getHeadNode(pageNode);
- headNode.addChild("meta", new String[]{"http-equiv",
"content"}, new String[]{"refresh", "20; url="});
- HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
-
- HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-error", desc));
- HTMLNode infoboxContent =
ctx.getPageMaker().getContentNode(infobox);
- infoboxContent.addChild("#", "Your freenet node is starting up,
please hold on.");
-
- WelcomeToadlet.maybeDisplayWrapperLogfile(ctx, contentNode);
- //TODO: send a Retry-After header ?
- writeHTMLReply(ctx, 503, desc, pageNode.generate());
- }
- }
-
- public String supportedMethods() {
- return "GET";
- }
- };
-
- private final StaticToadlet staticToadlet = new StaticToadlet(null);
-
- /**
- * Create a SimpleToadletServer, using the settings from the SubConfig
(the fproxy.*
- * config).
- */
- public StartupToadletServer(Executor executor, SimpleFieldSet config) {
- this.executor = executor;
- formPassword = String.valueOf(this.getClass().hashCode());
-
- // hack ... we don't have the config framework yet
- try {
- port = config.getInt("fproxy.port");
- bindTo = config.get("fproxy.bindTo");
- // Yeah, only FullAccess hosts here, it's on purpose.
- allowedHosts = config.get("fproxy.allowedHostsFullAccess");
- cssName = config.get("fproxy.css");
- } catch (Exception e) {
- port = SimpleToadletServer.DEFAULT_FPROXY_PORT;
- bindTo = NetworkInterface.DEFAULT_BIND_TO;
- allowedHosts = NetworkInterface.DEFAULT_BIND_TO;
- cssName = PageMaker.DEFAULT_THEME;
- }
-
- pageMaker = new PageMaker(cssName);
-
- boolean start = true;
- NetworkInterface ni = null;
- try {
- ni = NetworkInterface.create(port, bindTo, allowedHosts, executor,
true);
- } catch (IOException e) {
- e.printStackTrace();
- Logger.error(this, "Error starting SimpleToadletServer on "+
bindTo + ':' + port);
- System.err.println("Error starting SimpleToadletServer on "+
bindTo + ':' + port);
- start = false;
- }
- this.networkInterface = ni;
-
- if (start) {
- myThread = new Thread(this, "SimpleToadletServer");
- myThread.setDaemon(true);
- myThread.start();
- Logger.normal(this, "Starting SimpleToadletServer on " + port);
- System.out.println("Starting SimpleToadletServer on " + port);
- }
- }
-
- public void run() {
- try {
- networkInterface.setSoTimeout(500);
- } catch (SocketException e1) {
- Logger.error(this, "Could not set so-timeout to 500ms; on-the-fly
disabling of the interface will not work");
- }
- while (true) {
- synchronized (this) {
- if (myThread == null) {
- return;
- }
- }
- try {
- Socket conn = networkInterface.accept();
- if (Logger.shouldLog(Logger.MINOR, this)) {
- Logger.minor(this, "Accepted connection");
- }
- SocketHandler sh = new SocketHandler(conn);
- sh.start();
- } catch (SocketTimeoutException e) {
- // Go around again, this introduced to avoid blocking forever when
told to quit
- }
- }
- }
-
- public synchronized void kill() throws IOException {
- myThread = null;
- if(networkInterface != null)
- networkInterface.close();
- }
-
- public class SocketHandler implements Runnable {
-
- Socket sock;
-
- public SocketHandler(Socket conn) {
- this.sock = conn;
- }
-
- void start() {
- executor.execute(this, "SimpleToadletServer$SocketHandler@" +
hashCode());
- }
-
- public void run() {
- freenet.support.Logger.OSThread.logPID(this);
- boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
- if (logMINOR) {
- Logger.minor(this, "Handling connection");
- }
- try {
- ToadletContextImpl.handle(sock, container, bf, pageMaker);
- } catch (OutOfMemoryError e) {
- OOMHandler.handleOOM(e);
- System.err.println("SimpleToadletServer request above
failed.");
- } catch (Throwable t) {
- System.err.println("Caught in SimpleToadletServer: " + t);
- t.printStackTrace();
- Logger.error(this, "Caught in SimpleToadletServer: " + t, t);
- }
- if (logMINOR) {
- Logger.minor(this, "Handled connection");
- }
- }
- }
-
- public String getCSSName() {
- return this.cssName;
- }
-
- public void setCSSName(String name) {
- this.cssName = name;
- }
-
- private static String l10n(String key, String pattern, String value) {
- return L10n.getString("SimpleToadletServer." + key, pattern, value);
- }
-
- private static String l10n(String key) {
- return L10n.getString("SimpleToadletServer." + key);
- }
-}
Modified: trunk/freenet/src/freenet/clients/http/StaticToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StaticToadlet.java 2008-01-18
14:41:31 UTC (rev 17139)
+++ trunk/freenet/src/freenet/clients/http/StaticToadlet.java 2008-01-18
14:51:15 UTC (rev 17140)
@@ -6,7 +6,6 @@
import java.net.URI;
import freenet.client.DefaultMIMETypes;
-import freenet.client.HighLevelSimpleClient;
import freenet.l10n.L10n;
import freenet.support.api.Bucket;
import freenet.support.api.HTTPRequest;
@@ -16,8 +15,8 @@
* Serve up static files
*/
public class StaticToadlet extends Toadlet {
- StaticToadlet(HighLevelSimpleClient client) {
- super(client);
+ StaticToadlet() {
+ super(null);
}
public static final String ROOT_URL = "/static/";
Modified: trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
2008-01-18 14:41:31 UTC (rev 17139)
+++ trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
2008-01-18 14:51:15 UTC (rev 17140)
@@ -25,7 +25,9 @@
import freenet.support.api.Bucket;
import freenet.support.api.BucketFactory;
import freenet.support.io.BucketTools;
+import freenet.support.io.FileUtil;
import freenet.support.io.LineReadingInputStream;
+import freenet.support.io.NullOutputStream;
import freenet.support.io.TooLongException;
/**
@@ -213,7 +215,7 @@
/**
* Handle an incoming connection. Blocking, obviously.
*/
- public static void handle(Socket sock, ToadletContainer container,
BucketFactory bf, PageMaker pageMaker) {
+ public static void handle(Socket sock, ToadletContainer container,
BucketFactory bf, PageMaker pageMaker, boolean allowPost) {
try {
InputStream is = new
BufferedInputStream(sock.getInputStream(), 4096);
@@ -296,8 +298,17 @@
sendError(sock.getOutputStream(), 400, "Bad Request",
l10n("cannotParseContentLengthWithError", "error", e.toString()), true, null);
return;
}
+ if(allowPost) {
data = bf.makeBucket(len);
BucketTools.copyFrom(data, is, len);
+ } else {
+ // FIXME implement skipFully()
on FileUtil.
+ // Be polite: disappear the data
+ FileUtil.copy(is, new
NullOutputStream(), len);
+
ctx.sendMethodNotAllowed("POST", true);
+ ctx.close();
+ return;
+ }
} else {
// we're not doing to use it, but we
have to keep
// the compiler happy
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2008-01-18 14:41:31 UTC (rev
17139)
+++ trunk/freenet/src/freenet/node/Node.java 2008-01-18 14:51:15 UTC (rev
17140)
@@ -34,7 +34,7 @@
import com.sleepycat.je.util.DbDump;
import freenet.client.FetchContext;
-import freenet.clients.http.StartupToadletServer;
+import freenet.clients.http.SimpleToadletServer;
import freenet.config.EnumerableOptionCallback;
import freenet.config.FreenetFilePersistentConfig;
import freenet.config.InvalidConfigValueException;
@@ -108,6 +108,7 @@
import freenet.support.api.LongCallback;
import freenet.support.api.ShortCallback;
import freenet.support.api.StringCallback;
+import freenet.support.io.ArrayBucketFactory;
import freenet.support.io.Closer;
import freenet.support.io.FileUtil;
import freenet.support.transport.ip.HostnameSyntaxException;
@@ -389,9 +390,9 @@
public final long lastBootID;
public final long bootID;
public final long startupTime;
+
+ private SimpleToadletServer toadlets;
- private StartupToadletServer startupPageHolder;
-
public final NodeClientCore clientCore;
// The version we were before we restarted.
@@ -561,9 +562,26 @@
// Will be set up properly afterwards
L10n.setLanguage(L10n.FALLBACK_DEFAULT);
SimpleFieldSet oldConfig = config.getSimpleFieldSet();
- //a bit of a hack...
- if (oldConfig != null && oldConfig.getBoolean("fproxy.enabled",
true))
- startupPageHolder = new StartupToadletServer(executor,
oldConfig);
+ // Setup node-specific configuration
+ SubConfig nodeConfig = new SubConfig("node", config);
+ int sortOrder = 0;
+
+ // FProxy config needs to be here too
+ SubConfig fproxyConfig = new SubConfig("fproxy", config);
+
+ try {
+ toadlets = new SimpleToadletServer(fproxyConfig, new
ArrayBucketFactory(), executor);
+ } catch (IOException e4) {
+ Logger.error(this, "Could not start web interface:
"+e4, e4);
+ System.err.println("Could not start web interface:
"+e4);
+ e4.printStackTrace();
+ throw new
NodeInitException(NodeInitException.EXIT_COULD_NOT_START_FPROXY, "Could not
start FProxy: "+e4);
+ } catch (InvalidConfigValueException e4) {
+ System.err.println("Invalid config value, cannot start
web interface: "+e4);
+ e4.printStackTrace();
+ throw new
NodeInitException(NodeInitException.EXIT_COULD_NOT_START_FPROXY, "Could not
start FProxy: "+e4);
+ }
+
nodeNameUserAlert = new MeaningfulNodeNameUserAlert(this);
recentlyCompletedIDs = new LRUQueue();
this.config = config;
@@ -591,10 +609,6 @@
runningCHKPutUIDs = new HashSet();
runningSSKPutUIDs = new HashSet();
- // Setup node-specific configuration
- SubConfig nodeConfig = new SubConfig("node", config);
- int sortOrder = 0;
-
// Directory for node-related files other than store
nodeConfig.register("nodeDir", ".", sortOrder++, true, true /*
because can't be changed on the fly, also for packages */, "Node.nodeDir",
"Node.nodeDirLong",
@@ -1399,7 +1413,7 @@
nodeStats = new NodeStats(this, sortOrder, new
SubConfig("node.load", config), oldThrottleFS, obwLimit, ibwLimit);
- clientCore = new NodeClientCore(this, config, nodeConfig,
nodeDir, getDarknetPortNumber(), sortOrder, oldThrottleFS == null ? null :
oldThrottleFS.subset("RequestStarters"), oldConfig);
+ clientCore = new NodeClientCore(this, config, nodeConfig,
nodeDir, getDarknetPortNumber(), sortOrder, oldThrottleFS == null ? null :
oldThrottleFS.subset("RequestStarters"), oldConfig, fproxyConfig, toadlets);
nodeConfig.register("disableHangCheckers", false, sortOrder++,
true, false, "Node.disableHangCheckers", "Node.disableHangCheckersLong", new
BooleanCallback() {
@@ -2943,13 +2957,6 @@
return System.currentTimeMillis() - usm.getStartedTime();
}
- protected void killStartupToadlet() throws IOException {
- if (startupPageHolder!=null)
- startupPageHolder.kill();
- // Give it a chance to be GCed
- startupPageHolder = null;
- }
-
public synchronized UdpSocketHandler[] getPacketSocketHandlers() {
// FIXME better way to get these!
if(opennet != null) {
Modified: trunk/freenet/src/freenet/node/NodeClientCore.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeClientCore.java 2008-01-18 14:41:31 UTC
(rev 17139)
+++ trunk/freenet/src/freenet/node/NodeClientCore.java 2008-01-18 14:51:15 UTC
(rev 17140)
@@ -113,7 +113,7 @@
static final long MAX_ARCHIVED_FILE_SIZE = 1024*1024; // arbitrary...
FIXME
static final int MAX_CACHED_ELEMENTS = 256*1024; // equally arbitrary!
FIXME hopefully we can cache many of these though
- NodeClientCore(Node node, Config config, SubConfig nodeConfig, File
nodeDir, int portNumber, int sortOrder, SimpleFieldSet oldThrottleFS,
SimpleFieldSet oldConfig) throws NodeInitException {
+ NodeClientCore(Node node, Config config, SubConfig nodeConfig, File
nodeDir, int portNumber, int sortOrder, SimpleFieldSet oldThrottleFS,
SimpleFieldSet oldConfig, SubConfig fproxyConfig, SimpleToadletServer toadlets)
throws NodeInitException {
this.node = node;
this.nodeStats = node.nodeStats;
this.random = node.random;
@@ -345,14 +345,16 @@
throw new
NodeInitException(NodeInitException.EXIT_COULD_NOT_START_FCP, "Could not start
FCP: "+e);
}
- SubConfig fproxyConfig = new SubConfig("fproxy", config);
bookmarkManager = new BookmarkManager(this, oldConfig);
// FProxy
// FIXME this is a hack, the real way to do this is plugins
try {
- node.killStartupToadlet();
- toadletContainer =
FProxyToadlet.maybeCreateFProxyEtc(this, node, config, fproxyConfig);
+ toadletContainer = toadlets;
+ toadletContainer.setCore(this);
+ toadletContainer.setBucketFactory(tempBucketFactory);
+ FProxyToadlet.maybeCreateFProxyEtc(this, node, config,
fproxyConfig, toadletContainer);
+ toadletContainer.removeStartupToadlet();
} catch (IOException e) {
e.printStackTrace();
throw new
NodeInitException(NodeInitException.EXIT_COULD_NOT_START_FPROXY, "Could not
start FProxy: "+e);