-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Probably not, since this probably indicates that the user is already
running an instance of Freenet and has started another by mistake (if
they want to do it deliberately, they will change the ports manually).
Ian.
On 13 Apr 2006, at 07:14, Matthew Toseland wrote:
> Do we want the node to start up if it can't bind the FCP port?
>
> On Thu, Apr 13, 2006 at 01:38:39PM +0000, dbkr at freenetproject.org
> wrote:
>> Author: dbkr
>> Date: 2006-04-13 13:38:33 +0000 (Thu, 13 Apr 2006)
>> New Revision: 8535
>>
>> Modified:
>> trunk/freenet/src/freenet/node/Version.java
>> trunk/freenet/src/freenet/node/fcp/FCPServer.java
>> Log:
>> 640: Fix Crashing issue if we can't bind to the FCP Port, and fix
>> NPE and resulting config file corruption when FCP server is disabled.
>>
>>
>> Modified: trunk/freenet/src/freenet/node/Version.java
>> ===================================================================
>> --- trunk/freenet/src/freenet/node/Version.java 2006-04-13
>> 10:59:58 UTC (rev 8534)
>> +++ trunk/freenet/src/freenet/node/Version.java 2006-04-13
>> 13:38:33 UTC (rev 8535)
>> @@ -20,7 +20,7 @@
>> public static final String protocolVersion = "1.0";
>>
>> /** The build number of the current revision */
>> - private static final int buildNumber = 639;
>> + private static final int buildNumber = 640;
>>
>> /** Oldest build of Fred we will talk to */
>> private static final int lastGoodBuild = 591;
>>
>> Modified: trunk/freenet/src/freenet/node/fcp/FCPServer.java
>> ===================================================================
>> --- trunk/freenet/src/freenet/node/fcp/FCPServer.java 2006-04-13
>> 10:59:58 UTC (rev 8534)
>> +++ trunk/freenet/src/freenet/node/fcp/FCPServer.java 2006-04-13
>> 13:38:33 UTC (rev 8535)
>> @@ -11,6 +11,7 @@
>> import java.io.IOException;
>> import java.io.InputStreamReader;
>> import java.io.OutputStreamWriter;
>> +import java.net.BindException;
>> import java.net.InetAddress;
>> import java.net.ServerSocket;
>> import java.net.Socket;
>> @@ -67,29 +68,58 @@
>> persister = null;
>> }
>>
>> - public FCPServer(String ipToBindTo, int port, Node node, boolean
>> persistentDownloadsEnabled, String persistentDownloadsDir, long
>> persistenceInterval) throws IOException,
>> InvalidConfigValueException {
>> + public FCPServer(String ipToBindTo, int port, Node node, boolean
>> persistentDownloadsEnabled, String persistentDownloadsDir, long
>> persistenceInterval, boolean isEnabled) throws IOException,
>> InvalidConfigValueException {
>> this.bindTo = ipToBindTo;
>> this.persistenceInterval = persistenceInterval;
>> this.port = port;
>> - this.enabled = true;
>> - this.sock = new ServerSocket(port, 0, InetAddress.getByName
>> (bindTo));
>> - this.node = node;
>> - clientsByName = new WeakHashMap();
>> - // This one is only used to get the default settings.
>> Individual FCP conns
>> - // will make their own.
>> - HighLevelSimpleClient client = node.makeClient((short)0);
>> - defaultFetchContext = client.getFetcherContext();
>> - defaultInsertContext = client.getInserterContext();
>> - Thread t = new Thread(this, "FCP server");
>> + this.enabled = isEnabled;
>> this.enablePersistentDownloads = persistentDownloadsEnabled;
>> - globalClient = new FCPClient("Global Queue", this, null, true);
>> setPersistentDownloadsFile(new File(persistentDownloadsDir));
>> - t.setDaemon(true);
>> - t.start();
>> - if(enablePersistentDownloads) {
>> - loadPersistentRequests();
>> - startPersister();
>> +
>> + if (this.enabled) {
>> + this.node = node;
>> + clientsByName = new WeakHashMap();
>> +
>> +
>> + // This one is only used to get the default settings.
>> Individual FCP conns
>> + // will make their own.
>> + HighLevelSimpleClient client =
>> node.makeClient((short)0);
>> + defaultFetchContext = client.getFetcherContext();
>> + defaultInsertContext = client.getInserterContext();
>> +
>> +
>> + globalClient = new FCPClient("Global Queue", this,
>> null, true);
>> +
>> +
>> + if(enablePersistentDownloads) {
>> + loadPersistentRequests();
>> + startPersister();
>> + }
>> +
>> + Logger.normal(this, "Starting FCP server on
>> "+bindTo+":"+port
>> +".");
>> + ServerSocket tempsock = null;
>> + try {
>> + tempsock = new ServerSocket(port, 0,
>> InetAddress.getByName
>> (bindTo));
>> + } catch (BindException be) {
>> + Logger.error(this, "Couldn't bind to FCP Port
>> "+port+". FCP
>> Server not started.");
>> + }
>> +
>> + this.sock = tempsock;
>> +
>> + if (this.sock != null) {
>> + Thread t = new Thread(this, "FCP server");
>> + t.setDaemon(true);
>> + t.start();
>> + }
>> + } else {
>> + Logger.normal(this, "Not starting FCP server as it's
>> disabled");
>> + this.sock = null;
>> + this.node = null;
>> + this.clientsByName = null;
>> + this.globalClient = null;
>> + this.defaultFetchContext = null;
>> }
>> +
>> }
>>
>> public void run() {
>> @@ -243,20 +273,16 @@
>> long persistentDownloadsInterval = fcpConfig.getLong
>> ("persistentDownloadsInterval");
>>
>> FCPServer fcp;
>> - if(fcpConfig.getBoolean("enabled")){
>> - Logger.normal(node, "Starting FCP server on
>> "+fcpConfig.getString("bindTo")+":"+fcpConfig.getInt("port")+".");
>> - fcp = new FCPServer(fcpConfig.getString("bindTo"),
>> fcpConfig.getInt("port"), node, persistentDownloadsEnabled,
>> persistentDownloadsDir, persistentDownloadsInterval);
>> - node.setFCPServer(fcp);
>> -
>> - if(fcp != null) {
>> - cb1.server = fcp;
>> - cb2.server = fcp;
>> - cb3.server = fcp;
>> - }
>> - }else{
>> - Logger.normal(node, "Not starting FCP server as it's
>> disabled");
>> - fcp = null;
>> +
>> + fcp = new FCPServer(fcpConfig.getString("bindTo"),
>> fcpConfig.getInt("port"), node, persistentDownloadsEnabled,
>> persistentDownloadsDir, persistentDownloadsInterval,
>> fcpConfig.getBoolean("enabled"));
>> + node.setFCPServer(fcp);
>> +
>> + if(fcp != null) {
>> + cb1.server = fcp;
>> + cb2.server = fcp;
>> + cb3.server = fcp;
>> }
>> +
>>
>> fcpConfig.finishedInitialization();
>> return fcp;
>>
>> _______________________________________________
>> cvs mailing list
>> cvs at freenetproject.org
>> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
>>
>
> --
> Matthew J Toseland - toad at amphibian.dyndns.org
> Freenet Project Official Codemonkey - http://freenetproject.org/
> ICTHUS - Nothing is impossible. Our Boss says so.
> _______________________________________________
> Devl mailing list
> Devl at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (Darwin)
iD8DBQFEPngPQtgxRWSmsqwRAobFAJ4p2pAwV+4dVTZMSgjZmtW9yYL5QgCfZroe
776MdKnHTFn4wVmQtLozlwg=
=KzWO
-----END PGP SIGNATURE-----