Author: nextgens
Date: 2009-04-04 18:53:29 +0000 (Sat, 04 Apr 2009)
New Revision: 26532

Modified:
   trunk/freenet/src/freenet/io/comm/FreenetInetAddress.java
   trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
   trunk/freenet/src/freenet/node/AnnounceSender.java
   trunk/freenet/src/freenet/node/CHKInsertHandler.java
   trunk/freenet/src/freenet/node/FailureTable.java
   trunk/freenet/src/freenet/node/FailureTableEntry.java
   trunk/freenet/src/freenet/node/NodeIPDetector.java
   trunk/freenet/src/freenet/node/RequestHandler.java
   trunk/freenet/src/freenet/node/SendMessageOnErrorCallback.java
   trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java
   trunk/freenet/src/freenet/support/LRUHashtable.java
   trunk/freenet/src/freenet/support/SerialExecutor.java
Log:
Switch more classes to the new logging infrastructure

Modified: trunk/freenet/src/freenet/io/comm/FreenetInetAddress.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/FreenetInetAddress.java   2009-04-04 
15:59:50 UTC (rev 26531)
+++ trunk/freenet/src/freenet/io/comm/FreenetInetAddress.java   2009-04-04 
18:53:29 UTC (rev 26532)
@@ -11,6 +11,7 @@
 
 import freenet.io.AddressIdentifier;
 import freenet.support.Logger;
+import freenet.support.LogThresholdCallback;
 import freenet.support.transport.ip.HostnameSyntaxException;
 import freenet.support.transport.ip.HostnameUtil;
 import freenet.support.transport.ip.IPUtil;
@@ -24,6 +25,18 @@
  */
 public class FreenetInetAddress {
 
+       private static volatile boolean logMINOR;
+       private static volatile boolean logDEBUG;
+
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback(){
+                       public void shouldUpdate(){
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                               logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
+                       }
+               });
+       }
+
        // hostname - only set if we were created with a hostname
        // and not an address
        private final String hostname;
@@ -36,12 +49,12 @@
                int firstByte = dis.readUnsignedByte();
                byte[] ba;
                if(firstByte == 255) {
-                       if(Logger.shouldLog(Logger.MINOR, this)) 
Logger.minor(this, "New format IPv6 address");
+                       if(logMINOR) Logger.minor(this, "New format IPv6 
address");
                        // New format IPv6 address
                        ba = new byte[16];
                        dis.readFully(ba);
                } else if(firstByte == 0) {
-                       if(Logger.shouldLog(Logger.MINOR, this)) 
Logger.minor(this, "New format IPv4 address");
+                       if(logMINOR) Logger.minor(this, "New format IPv4 
address");
                        // New format IPv4 address
                        ba = new byte[4];
                        dis.readFully(ba);
@@ -64,12 +77,12 @@
                int firstByte = dis.readUnsignedByte();
                byte[] ba;
                if(firstByte == 255) {
-                       if(Logger.shouldLog(Logger.MINOR, this)) 
Logger.minor(this, "New format IPv6 address");
+                       if(logMINOR) Logger.minor(this, "New format IPv6 
address");
                        // New format IPv6 address
                        ba = new byte[16];
                        dis.readFully(ba);
                } else if(firstByte == 0) {
-                       if(Logger.shouldLog(Logger.MINOR, this)) 
Logger.minor(this, "New format IPv4 address");
+                       if(logMINOR) Logger.minor(this, "New format IPv4 
address");
                        // New format IPv4 address
                        ba = new byte[4];
                        dis.readFully(ba);
@@ -108,7 +121,6 @@
         // if we were created with an explicit IP address, use it as such
         // debugging log messages because AddressIdentifier doesn't appear to 
handle all IPv6 literals correctly, such as "fe80::204:1234:dead:beef"
         AddressIdentifier.AddressType addressType = 
AddressIdentifier.getAddressType(host);
-        boolean logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
         if(logDEBUG) Logger.debug(this, "Address type of '"+host+"' appears to 
be '"+addressType+ '\'');
         if(addressType != AddressIdentifier.AddressType.OTHER) {
                // Is an IP address
@@ -139,7 +151,6 @@
         // if we were created with an explicit IP address, use it as such
         // debugging log messages because AddressIdentifier doesn't appear to 
handle all IPv6 literals correctly, such as "fe80::204:1234:dead:beef"
         AddressIdentifier.AddressType addressType = 
AddressIdentifier.getAddressType(host);
-        boolean logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
         if(logDEBUG) Logger.debug(this, "Address type of '"+host+"' appears to 
be '"+addressType+ '\'');
         if(addressType != AddressIdentifier.AddressType.OTHER) {
             try {
@@ -264,7 +275,6 @@
         */
        public InetAddress getHandshakeAddress() {
            // Since we're handshaking, hostname-to-IP may have changed
-               boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
            if ((_address != null) && (hostname == null)) {
                if(logMINOR) Logger.minor(this, "hostname is null, returning 
"+_address);
                return _address;

Modified: trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
===================================================================
--- trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java     2009-04-04 
15:59:50 UTC (rev 26531)
+++ trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java     2009-04-04 
18:53:29 UTC (rev 26532)
@@ -34,6 +34,7 @@
 import freenet.support.BitArray;
 import freenet.support.Executor;
 import freenet.support.Logger;
+import freenet.support.LogThresholdCallback;
 import freenet.support.TimeUtil;
 import freenet.support.io.NativeThread;
 import freenet.support.math.MedianMeanRunningAverage;
@@ -46,6 +47,16 @@
  */
 public class BlockTransmitter {
 
+       private static volatile boolean logMINOR;
+
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback(){
+                       public void shouldUpdate(){
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
+
        public static final int SEND_TIMEOUT = 60000;
        public static final int PING_EVERY = 8;
        
@@ -126,7 +137,7 @@
                                                        //No unsent packets, no 
unreceived packets
                                                        
sendAllSentNotification();
                                                        timeAllSent = 
System.currentTimeMillis();
-                                                       
if(Logger.shouldLog(Logger.MINOR, this))
+                                                       if(logMINOR)
                                                                
Logger.minor(this, "Sent all blocks, none unsent");
                                                        
_senderThread.notifyAll();
                                                }
@@ -188,7 +199,6 @@
                                        if(_sendComplete) return false;
                                }
                                Message msg;
-                               boolean logMINOR = 
Logger.shouldLog(Logger.MINOR, this);
                                try {
                                        MessageFilter 
mfMissingPacketNotification = 
MessageFilter.create().setType(DMT.missingPacketNotification).setField(DMT.UID, 
_uid).setTimeout(SEND_TIMEOUT).setSource(_destination);
                                        MessageFilter mfAllReceived = 
MessageFilter.create().setType(DMT.allReceived).setField(DMT.UID, 
_uid).setTimeout(SEND_TIMEOUT).setSource(_destination);

Modified: trunk/freenet/src/freenet/node/AnnounceSender.java
===================================================================
--- trunk/freenet/src/freenet/node/AnnounceSender.java  2009-04-04 15:59:50 UTC 
(rev 26531)
+++ trunk/freenet/src/freenet/node/AnnounceSender.java  2009-04-04 18:53:29 UTC 
(rev 26532)
@@ -14,11 +14,22 @@
 import freenet.io.comm.PeerParseException;
 import freenet.io.comm.ReferenceSignatureVerificationException;
 import freenet.support.Logger;
+import freenet.support.LogThresholdCallback;
 import freenet.support.SimpleFieldSet;
 import freenet.support.io.NativeThread;
 
 public class AnnounceSender implements PrioRunnable, ByteCounter {
+       private static volatile boolean logMINOR;
 
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback(){
+                       public void shouldUpdate(){
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
+
+
     // Constants
     static final int ACCEPTED_TIMEOUT = 10000;
     static final int ANNOUNCE_TIMEOUT = 240000; // longer than a regular 
request as have to transfer noderefs hop by hop etc
@@ -33,7 +44,6 @@
        private int noderefLength;
        private short htl;
        private double target;
-       private static boolean logMINOR;
        private final AnnouncementCallback cb;
        private final PeerNode onlyNode;
        
@@ -46,7 +56,6 @@
                this.onlyNode = null;
                htl = (short) Math.min(m.getShort(DMT.HTL), node.maxHTL());
                target = m.getDouble(DMT.TARGET_LOCATION); // FIXME validate
-               logMINOR = Logger.shouldLog(Logger.MINOR, this);
                cb = null;
        }
 
@@ -61,7 +70,6 @@
                this.cb = cb;
                this.onlyNode = onlyNode;
                noderefBuf = om.crypto.myCompressedFullRef();
-               logMINOR = Logger.shouldLog(Logger.MINOR, this);
        }
        
        public void run() {

Modified: trunk/freenet/src/freenet/node/CHKInsertHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/CHKInsertHandler.java        2009-04-04 
15:59:50 UTC (rev 26531)
+++ trunk/freenet/src/freenet/node/CHKInsertHandler.java        2009-04-04 
18:53:29 UTC (rev 26532)
@@ -18,6 +18,7 @@
 import freenet.keys.NodeCHK;
 import freenet.support.HexUtil;
 import freenet.support.Logger;
+import freenet.support.LogThresholdCallback;
 import freenet.support.OOMHandler;
 import freenet.support.ShortBuffer;
 import freenet.support.io.NativeThread;
@@ -29,7 +30,15 @@
  * This corresponds to RequestHandler.
  */
 public class CHKInsertHandler implements PrioRunnable, ByteCounter {
+       private static volatile boolean logMINOR;
 
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback(){
+                       public void shouldUpdate(){
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
 
     static final int DATA_INSERT_TIMEOUT = 10000;
     
@@ -46,7 +55,6 @@
     private Thread runThread;
     PartiallyReceivedBlock prb;
     final InsertTag tag;
-    private static boolean logMINOR;
     
     CHKInsertHandler(Message req, PeerNode source, long id, Node node, long 
startTime, InsertTag tag) {
         this.req = req;
@@ -58,7 +66,6 @@
         key = (NodeCHK) req.getObject(DMT.FREENET_ROUTING_KEY);
         htl = req.getShort(DMT.HTL);
         if(htl <= 0) htl = 1;
-        logMINOR = Logger.shouldLog(Logger.MINOR, this);
         receivedBytes(req.receivedByteCount());
     }
     

Modified: trunk/freenet/src/freenet/node/FailureTable.java
===================================================================
--- trunk/freenet/src/freenet/node/FailureTable.java    2009-04-04 15:59:50 UTC 
(rev 26531)
+++ trunk/freenet/src/freenet/node/FailureTable.java    2009-04-04 18:53:29 UTC 
(rev 26532)
@@ -21,6 +21,7 @@
 import freenet.keys.SSKBlock;
 import freenet.support.LRUHashtable;
 import freenet.support.Logger;
+import freenet.support.LogThresholdCallback;
 import freenet.support.OOMHandler;
 import freenet.support.OOMHook;
 import freenet.support.SerialExecutor;
@@ -42,6 +43,18 @@
  */
 public class FailureTable implements OOMHook {
        
+       private static volatile boolean logMINOR;
+       private static volatile boolean logDEBUG;
+
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback(){
+                       public void shouldUpdate(){
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                               logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
+                       }
+               });
+       }
+
        /** FailureTableEntry's by key. Note that we push an entry only when 
sentTime changes. */
        private final LRUHashtable<Key,FailureTableEntry> entriesByKey;
        /** BlockOfferList by key */
@@ -63,17 +76,12 @@
        /** Clean up old data every 30 minutes to save memory and improve 
privacy */
        static final int CLEANUP_PERIOD = 30*60*1000;
        
-       static boolean logMINOR;
-       static boolean logDEBUG;
-       
        FailureTable(Node node) {
                entriesByKey = new LRUHashtable<Key,FailureTableEntry>();
                blockOfferListByKey = new LRUHashtable<Key,BlockOfferList>();
                this.node = node;
                offerAuthenticatorKey = new byte[32];
                node.random.nextBytes(offerAuthenticatorKey);
-               logMINOR = Logger.shouldLog(Logger.MINOR, this);
-               logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
                offerExecutor = new SerialExecutor(NativeThread.HIGH_PRIORITY);
                node.ps.queueTimedJob(new FailureTableCleaner(), 
CLEANUP_PERIOD);
        }
@@ -597,8 +605,6 @@
                }
 
                private void realRun() {
-                       logMINOR = Logger.shouldLog(Logger.MINOR, 
FailureTable.this);
-                       logDEBUG = Logger.shouldLog(Logger.DEBUG, 
FailureTable.this);
                        if(logMINOR) Logger.minor(this, "Starting FailureTable 
cleanup");
                        long startTime = System.currentTimeMillis();
                        FailureTableEntry[] entries;

Modified: trunk/freenet/src/freenet/node/FailureTableEntry.java
===================================================================
--- trunk/freenet/src/freenet/node/FailureTableEntry.java       2009-04-04 
15:59:50 UTC (rev 26531)
+++ trunk/freenet/src/freenet/node/FailureTableEntry.java       2009-04-04 
18:53:29 UTC (rev 26532)
@@ -9,6 +9,7 @@
 
 import freenet.keys.Key;
 import freenet.support.Logger;
+import freenet.support.LogThresholdCallback;
 
 class FailureTableEntry implements TimedOutNodesList {
        
@@ -513,4 +514,4 @@
                return isEmpty(System.currentTimeMillis());
        }
 
-}
\ No newline at end of file
+}

Modified: trunk/freenet/src/freenet/node/NodeIPDetector.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeIPDetector.java  2009-04-04 15:59:50 UTC 
(rev 26531)
+++ trunk/freenet/src/freenet/node/NodeIPDetector.java  2009-04-04 18:53:29 UTC 
(rev 26532)
@@ -25,6 +25,7 @@
 import freenet.pluginmanager.FredPluginPortForward;
 import freenet.support.HTMLNode;
 import freenet.support.Logger;
+import freenet.support.LogThresholdCallback;
 import freenet.support.api.StringCallback;
 import freenet.support.transport.ip.HostnameSyntaxException;
 import freenet.support.transport.ip.IPAddressDetector;
@@ -35,7 +36,16 @@
  * information (NodeCrypto - UdpSocketHandler etc).
  */
 public class NodeIPDetector {
+       private static volatile boolean logMINOR;
 
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback(){
+                       public void shouldUpdate(){
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
+
        /** Parent node */
        final Node node;
        /** Ticker */
@@ -113,7 +123,6 @@
                        addedValidIP |= innerDetect(addresses);
                }
                
-               boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
                if(node.clientCore != null) {
                        boolean hadValidIP;
                        synchronized(this) {
@@ -176,7 +185,6 @@
         * @return
         */
        private boolean innerDetect(List<FreenetInetAddress> addresses) {
-               boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
                boolean addedValidIP = false;
                InetAddress[] detectedAddrs = ipDetector.getAddress();
                assert(detectedAddrs != null);
@@ -321,7 +329,7 @@
                if(addrs == null || addrs.length == 0) return false;
                for(int i=0;i<addrs.length;i++) {
                        if(IPUtil.isValidAddress(addrs[i], false)) {
-                               if(Logger.shouldLog(Logger.MINOR, this))
+                               if(logMINOR)
                                        Logger.minor(this, "Has a directly 
detected IP: "+addrs[i]);
                                return true;
                        }
@@ -514,7 +522,7 @@
        }
 
        void hasDetectedPM() {
-               if(Logger.shouldLog(Logger.MINOR, this))
+               if(logMINOR)
                        Logger.minor(this, "hasDetectedPM() called", new 
Exception("debug"));
                synchronized(this) {
                        hasDetectedPM = true;

Modified: trunk/freenet/src/freenet/node/RequestHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestHandler.java  2009-04-04 15:59:50 UTC 
(rev 26531)
+++ trunk/freenet/src/freenet/node/RequestHandler.java  2009-04-04 18:53:29 UTC 
(rev 26532)
@@ -21,6 +21,7 @@
 import freenet.keys.NodeSSK;
 import freenet.keys.SSKBlock;
 import freenet.support.Logger;
+import freenet.support.LogThresholdCallback;
 import freenet.support.SimpleFieldSet;
 import freenet.support.TimeUtil;
 import freenet.support.io.NativeThread;
@@ -32,7 +33,15 @@
  */
 public class RequestHandler implements PrioRunnable, ByteCounter, 
RequestSender.Listener {
 
-       private static boolean logMINOR;
+       private static volatile boolean logMINOR;
+
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback(){
+                       public void shouldUpdate(){
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
        final Message req;
        final Node node;
        final long uid;
@@ -68,7 +77,6 @@
                this.key = key;
                if(key instanceof NodeSSK)
                        needsPubKey = m.getBoolean(DMT.NEED_PUB_KEY);
-               logMINOR = Logger.shouldLog(Logger.MINOR, this);
                receivedBytes(m.receivedByteCount());
        }
 

Modified: trunk/freenet/src/freenet/node/SendMessageOnErrorCallback.java
===================================================================
--- trunk/freenet/src/freenet/node/SendMessageOnErrorCallback.java      
2009-04-04 15:59:50 UTC (rev 26531)
+++ trunk/freenet/src/freenet/node/SendMessageOnErrorCallback.java      
2009-04-04 18:53:29 UTC (rev 26532)
@@ -8,13 +8,23 @@
 import freenet.io.comm.Message;
 import freenet.io.comm.NotConnectedException;
 import freenet.support.Logger;
+import freenet.support.LogThresholdCallback;
 
 /**
  * If the send fails, send the given message to the given node.
  * Otherwise do nothing.
  */
 public class SendMessageOnErrorCallback implements AsyncMessageCallback {
+       private static volatile boolean logMINOR;
 
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback(){
+                       public void shouldUpdate(){
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
+
     @Override
        public String toString() {
         return super.toString() + ": "+msg+ ' ' +dest;
@@ -28,7 +38,7 @@
         this.msg = message;
         this.dest = pn;
         this.ctr = ctr;
-        if(Logger.shouldLog(Logger.MINOR, this))
+        if(logMINOR)
                Logger.minor(this, "Created "+this);
     }
 
@@ -41,12 +51,12 @@
     }
 
     public void disconnected() {
-       if(Logger.shouldLog(Logger.MINOR, this))
+       if(logMINOR)
                Logger.minor(this, "Disconnect trigger: "+this);
         try {
             dest.sendAsync(msg, null, ctr);
         } catch (NotConnectedException e) {
-               if(Logger.shouldLog(Logger.MINOR, this))
+               if(logMINOR)
                        Logger.minor(this, "Both source and destination 
disconnected: "+msg+" for "+this);
         }
     }

Modified: trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java      
2009-04-04 15:59:50 UTC (rev 26531)
+++ trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java      
2009-04-04 18:53:29 UTC (rev 26532)
@@ -49,6 +49,7 @@
 import freenet.node.useralerts.UserAlert;
 import freenet.support.HTMLNode;
 import freenet.support.Logger;
+import freenet.support.LogThresholdCallback;
 import freenet.support.SizeUtil;
 import freenet.support.TimeUtil;
 import freenet.support.io.FileBucket;
@@ -63,6 +64,16 @@
  */
 public class UpdateOverMandatoryManager implements RequestClient {
 
+       private static volatile boolean logMINOR;
+
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback(){
+                       public void shouldUpdate(){
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
+
        final NodeUpdateManager updateManager;
        /** Set of PeerNode's which say (or said before they disconnected) 
         * the key has been revoked */
@@ -88,7 +99,6 @@
        static final int REQUEST_MAIN_JAR_TIMEOUT = 60 * 1000;
        //** Grace time before we use UoM to update */
        public static final int GRACE_TIME = 3 * 60 * 60 * 1000; // 3h
-       private boolean logMINOR;
        private UserAlert alert;
        private static final Pattern extBuildNumberPattern = 
Pattern.compile("^ext(?:-jar)?-(\\d+)\\.fblob$");
        private static final Pattern mainBuildNumberPattern = 
Pattern.compile("^main(?:-jar)?-(\\d+)\\.fblob$");
@@ -106,7 +116,6 @@
                nodesAskedSendExtJar = new HashSet<PeerNode>();
                nodesSendingMainJar = new HashSet<PeerNode>();
                nodesSendingExtJar = new HashSet<PeerNode>();
-               logMINOR = Logger.shouldLog(Logger.MINOR, this);
        }
 
        /** 
@@ -133,7 +142,6 @@
 
                // Log it
 
-               logMINOR = Logger.shouldLog(Logger.MINOR, this);
                if(logMINOR) {
                        Logger.minor(this, "Update Over Mandatory offer from 
node " + source.getPeer() + " : " + source.userToString() + ":");
                        Logger.minor(this, "Main jar key: " + mainJarKey + " 
version=" + mainJarVersion + " length=" + mainJarFileLength);

Modified: trunk/freenet/src/freenet/support/LRUHashtable.java
===================================================================
--- trunk/freenet/src/freenet/support/LRUHashtable.java 2009-04-04 15:59:50 UTC 
(rev 26531)
+++ trunk/freenet/src/freenet/support/LRUHashtable.java 2009-04-04 18:53:29 UTC 
(rev 26532)
@@ -4,7 +4,16 @@
 import java.util.Hashtable;
 
 public class LRUHashtable<K, V> {
+       private static volatile boolean logMINOR;
 
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback(){
+                       public void shouldUpdate(){
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
+
     /*
      * I've just converted this to using the DLList and Hashtable
      * this makes it Hashtable time instead of O(N) for push and
@@ -30,7 +39,7 @@
                insert.value = value;
             list.remove(insert);
         }
-        if(Logger.shouldLog(Logger.MINOR, this))
+        if(logMINOR)
                Logger.minor(this, "Pushed "+insert+" ( "+key+ ' ' +value+" )");
 
         list.unshift(insert);

Modified: trunk/freenet/src/freenet/support/SerialExecutor.java
===================================================================
--- trunk/freenet/src/freenet/support/SerialExecutor.java       2009-04-04 
15:59:50 UTC (rev 26531)
+++ trunk/freenet/src/freenet/support/SerialExecutor.java       2009-04-04 
18:53:29 UTC (rev 26532)
@@ -8,6 +8,16 @@
 
 public class SerialExecutor implements Executor {
 
+       private static volatile boolean logMINOR;
+
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback(){
+                       public void shouldUpdate(){
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
+
        private final LinkedBlockingQueue<Runnable> jobs;
        private final Object syncLock;
        private final int priority;
@@ -69,11 +79,11 @@
                this.name=name;
                synchronized (syncLock) {
                        if (!jobs.isEmpty())
-                               reallyStart(Logger.shouldLog(Logger.MINOR, 
this));
+                               reallyStart();
                }
        }
        
-       private void reallyStart(boolean logMINOR) {
+       private void reallyStart() {
                synchronized (syncLock) {
                threadStarted=true;
                }
@@ -83,7 +93,6 @@
        }
        
        public void execute(Runnable job, String jobName) {
-               boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
                if (logMINOR)
                        Logger.minor(this, "Running " + jobName + " : " + job + 
" started=" + threadStarted + " waiting="
                                + threadWaiting);
@@ -91,7 +100,7 @@
 
                synchronized (syncLock) {
                        if (!threadStarted && realExecutor != null)
-                               reallyStart(logMINOR);
+                               reallyStart();
                }
        }
 

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to