1. Is it necessary to close the underlying stream? I was under the
impression that wrapper streams close method will close that which they
wrap, and closing the underlying stream as well will result in an
IOException to the effect that it is already closed.
2. You can't synchronize on an object you suspect may be null.
On Wed, Jul 05, 2006 at 10:10:42AM +0000, nextgens at freenetproject.org wrote:
> Author: nextgens
> Date: 2006-07-05 10:10:36 +0000 (Wed, 05 Jul 2006)
> New Revision: 9468
>
> Modified:
> trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
> trunk/freenet/src/freenet/node/CPUUsageMonitor.java
> trunk/freenet/src/freenet/node/Node.java
> trunk/freenet/src/freenet/node/PeerNode.java
> trunk/freenet/src/freenet/node/TextModeClientInterfaceServer.java
> Log:
> Various bug fixes:
> * Fix some problems in StringCallbacks
> * Fix a potential synchronization problems
> * Limit the visibility of some classes
> * add a FIXME : it needs to be reviewed !
>
> Modified: trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
> ===================================================================
> --- trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
> 2006-07-05 08:28:11 UTC (rev 9467)
> +++ trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
> 2006-07-05 10:10:36 UTC (rev 9468)
> @@ -35,7 +35,7 @@
>
> public class SimpleToadletServer implements ToadletContainer, Runnable {
>
> - public class ToadletElement {
> + private static class ToadletElement {
> public ToadletElement(Toadlet t2, String urlPrefix) {
> t = t2;
> prefix = urlPrefix;
> @@ -76,7 +76,7 @@
> }
>
> public void set(String bindTo) throws
> InvalidConfigValueException {
> - if(bindTo != get())
> + if(!bindTo.equals(get()))
> throw new InvalidConfigValueException("Cannot
> change FProxy bind address on the fly");
> }
> }
> @@ -133,7 +133,7 @@
> }
> }
>
> - class FProxyAdvancedDarknetEnabledCallback implements BooleanCallback {
> + private static class FProxyAdvancedDarknetEnabledCallback implements
> BooleanCallback {
>
> private final SimpleToadletServer ts;
>
>
> Modified: trunk/freenet/src/freenet/node/CPUUsageMonitor.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/CPUUsageMonitor.java 2006-07-05
> 08:28:11 UTC (rev 9467)
> +++ trunk/freenet/src/freenet/node/CPUUsageMonitor.java 2006-07-05
> 10:10:36 UTC (rev 9468)
> @@ -39,6 +39,7 @@
> firstline = br.readLine();
> if(firstline == null) throw new EOFException();
> ris.close();
> + br.close();
> } catch (IOException e) {
> if(!reportedFailedProcOpen)
> Logger.error(this, "Failed to open /proc/stat: "+e, e);
>
> Modified: trunk/freenet/src/freenet/node/Node.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/Node.java 2006-07-05 08:28:11 UTC (rev
> 9467)
> +++ trunk/freenet/src/freenet/node/Node.java 2006-07-05 10:10:36 UTC (rev
> 9468)
> @@ -653,7 +653,7 @@
> private static NodeStarter nodeStarter;
>
> // The watchdog will be silenced until it's true
> - private static boolean hasStarted = false;
> + private boolean hasStarted = false;
>
> // Debugging stuff
> private static final boolean USE_RAM_PUBKEYS_CACHE = true;
>
> Modified: trunk/freenet/src/freenet/node/PeerNode.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/PeerNode.java 2006-07-05 08:28:11 UTC
> (rev 9467)
> +++ trunk/freenet/src/freenet/node/PeerNode.java 2006-07-05 10:10:36 UTC
> (rev 9468)
> @@ -286,6 +286,17 @@
> // FIXME make mandatory once everyone has upgraded
> lastGoodVersion = fs.get("lastGoodVersion");
>
> + String name = fs.get("myName");
> + if(name == null) throw new FSParseException("No name");
> + myName = name;
> + String testnet = fs.get("testnet");
> + testnetEnabled = testnet == null ? false :
> (testnet.equalsIgnoreCase("true") || testnet.equalsIgnoreCase("yes"));
> + if(testnetEnabled != node.testnetEnabled) {
> + String err = "Ignoring incompatible node "+detectedPeer+" -
> peer.testnet="+testnetEnabled+"("+testnet+") but
> node.testnet="+node.testnetEnabled;
> + Logger.error(this, err);
> + throw new PeerParseException(err);
> + }
> +
> nominalPeer=new Vector();
> nominalPeer.removeAllElements();
> try{
> @@ -312,17 +323,6 @@
> detectedPeer = (Peer) nominalPeer.firstElement();
> }
>
> - String name = fs.get("myName");
> - if(name == null) throw new FSParseException("No name");
> - myName = name;
> - String testnet = fs.get("testnet");
> - testnetEnabled = testnet == null ? false :
> (testnet.equalsIgnoreCase("true") || testnet.equalsIgnoreCase("yes"));
> - if(testnetEnabled != node.testnetEnabled) {
> - String err = "Ignoring incompatible node "+detectedPeer+" -
> peer.testnet="+testnetEnabled+"("+testnet+") but
> node.testnet="+node.testnetEnabled;
> - Logger.error(this, err);
> - throw new PeerParseException(err);
> - }
> -
> // Setup incoming and outgoing setup ciphers
> byte[] nodeKey = node.identityHash;
> byte[] nodeKeyHash = node.identityHashHash;
> @@ -481,6 +481,7 @@
> return false;
> }
>
> + //FIXME: Huh wtf ?
> private void randomizeMaxTimeBetweenPacketSends() {
> int x = Node.KEEPALIVE_INTERVAL;
> x += node.random.nextInt(x);
> @@ -500,7 +501,7 @@
> /**
> * Returns an array with the advertised addresses and the detected one
> */
> - public Peer[] getHandshakeIPs(){
> + protected Peer[] getHandshakeIPs(){
> return handshakeIPs;
> }
>
> @@ -941,10 +942,12 @@
> * Send a message, right now, on this thread, to this node.
> */
> public void send(Message req) throws NotConnectedException {
> - if(!isConnected) {
> - Logger.error(this, "Tried to send "+req+" but not connected to
> "+this, new Exception("debug"));
> - return;
> - }
> + synchronized (this) {
> + if(!isConnected()) {
> + Logger.error(this, "Tried to send "+req+" but not connected
> to "+this, new Exception("debug"));
> + return;
> + }
> + }
> node.usm.send(this, req);
> }
>
> @@ -1537,11 +1540,13 @@
> fs.put("testnet", Boolean.toString(testnetEnabled));
> fs.put("version", version);
> fs.put("myName", myName);
> - if(myARK != null) {
> - // Decrement it because we keep the number we would like to
> fetch, not the last one fetched.
> - fs.put("ark.number", Long.toString(myARK.suggestedEdition-1));
> - fs.put("ark.pubURI", myARK.getBaseSSK().toString(false));
> - }
> + synchronized (myARK) {
> + if(myARK != null) {
> + // Decrement it because we keep the number we would like to
> fetch, not the last one fetched.
> + fs.put("ark.number", Long.toString(myARK.suggestedEdition-1));
> + fs.put("ark.pubURI", myARK.getBaseSSK().toString(false));
> + }
> + }
> return fs;
> }
>
> @@ -1850,11 +1855,13 @@
> localNodeReceivedMessageTypes.put(messageSpecName,count);
> }
>
> + //FIXME: maybe return a copy insteed
> public Hashtable getLocalNodeSentMessagesToStatistic ()
> {
> return localNodeSentMessageTypes;
> }
> -
> +
> + //FIXME: maybe return a copy insteed
> public Hashtable getLocalNodeReceivedMessagesFromStatistic ()
> {
> return localNodeReceivedMessageTypes;
>
> Modified: trunk/freenet/src/freenet/node/TextModeClientInterfaceServer.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/TextModeClientInterfaceServer.java
> 2006-07-05 08:28:11 UTC (rev 9467)
> +++ trunk/freenet/src/freenet/node/TextModeClientInterfaceServer.java
> 2006-07-05 10:10:36 UTC (rev 9468)
> @@ -149,7 +149,7 @@
> }
>
> public void set(String val) throws InvalidConfigValueException {
> - if(val == get()) return;
> + if(val.equals(get())) return;
> throw new InvalidConfigValueException("Cannot be updated on the
> fly");
> }
> }
>
> _______________________________________________
> 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL:
<https://emu.freenetproject.org/pipermail/cvs/attachments/20060705/7253ccdc/attachment.pgp>