Author: toad
Date: 2008-09-01 15:45:18 +0000 (Mon, 01 Sep 2008)
New Revision: 22302

Modified:
   trunk/freenet/src/freenet/support/LoggerHook.java
Log:
Now fix shouldLog() contention properly.


Modified: trunk/freenet/src/freenet/support/LoggerHook.java
===================================================================
--- trunk/freenet/src/freenet/support/LoggerHook.java   2008-09-01 15:43:12 UTC 
(rev 22301)
+++ trunk/freenet/src/freenet/support/LoggerHook.java   2008-09-01 15:45:18 UTC 
(rev 22302)
@@ -200,16 +200,19 @@
        }

        public boolean instanceShouldLog(int priority, Class<?> c) {
-               int thresh = threshold;
-               if ((c != null) && (detailedThresholds.length > 0)) {
+               DetailedThreshold[] threshholds;
+               int thresh;
+               synchronized(this) {
+                       threshholds = detailedThresholds;
+                       thresh = threshold;
+               }
+               if ((c != null) && (threshholds.length > 0)) {
                        String cname = c.getName();
-                       synchronized(this) {
-                               for(int i = 0; i < detailedThresholds.length; 
i++) {
-                                       DetailedThreshold dt = 
detailedThresholds[i];
+                               for(int i = 0; i < threshholds.length; i++) {
+                                       DetailedThreshold dt = threshholds[i];
                                        if(cname.startsWith(dt.section))
                                                thresh = dt.dThreshold;
                                }
-                       }
                }
                return priority >= thresh;
        }


Reply via email to