Bryan Thompson wrote:
Peter,

Rather than testing against the trunk, I would prefer to test the change 
against the 2.2 release.  That will allow me to avoid validating the entire 
state of the trunk and let me focus on whether the change fixes the specific 
DGC problem.

It looks like [1] is the commit containing this fix.  Can I simply apply that 
patch to the clean checkout of 2.2?

Thanks,
Bryan

[1] 
http://mail-archives.apache.org/mod_mbox/river-commits/201201.mbox/%3C20120114105227.9890723888E7%40eris.apache.org%3E


Yes,

See attached.

Regards,

Peter.
--- river/jtsk/trunk/src/com/sun/jini/jeri/internal/runtime/ObjectTable.java	2011/06/19 00:43:42	1137269
+++ river/jtsk/skunk/peterConcurrentPolicy/src/com/sun/jini/jeri/internal/runtime/ObjectTable.java	2012/01/13 11:54:29	1231027
@@ -64,8 +64,11 @@
     /** thread to check for expired leases */
     private Thread leaseChecker;
     
-    /** thread guard */
-    private Boolean running;
+    /** expired lease thread guard */
+    private final Object runLock;
+    
+    /** flag to indicate expired lease thread started */
+    private volatile boolean running;
 
     ObjectTable() { 
         requestDispatchersLock = new Object();
@@ -73,7 +76,8 @@
         keepAliveCount = new JvmLifeSupport();
         leaseTable = new ConcurrentHashMap<Uuid,Lease>(256);//Plenty of capacity to reduce resizing.
         leaseChecker = null;
-        running = Boolean.FALSE;
+        running = false;
+        runLock = new Object();
     }
 
     RequestDispatcher createRequestDispatcher(Unreferenced unrefCallback) {
@@ -289,13 +293,17 @@
              * Then because the late clean call sequence number is less than the 
              * second dirty call and exists, it is correctly recognised.
              */
-            synchronized (running){
-                if (!running) {
-                    leaseChecker =
-                        (Thread) AccessController.doPrivileged(
-                            new NewThreadAction(new LeaseChecker(),
-                                "DGC Lease Checker", true));
-                    leaseChecker.start();
+            // This must be performed after changing the leaseTable
+            if (!running){ // double checked
+                synchronized (runLock){
+                    if (!running) {
+                        leaseChecker =
+                            (Thread) AccessController.doPrivileged(
+                                new NewThreadAction(new LeaseChecker(),
+                                    "DGC Lease Checker", true));
+                        leaseChecker.start();
+                        running = true;
+                    }
                 }
             }
             for (int i = 0; i < ids.length; i++) {
@@ -359,9 +367,9 @@
                 // This is always executed and returns the lease checker
                 // to the non running state, such that if the application
                 // has not exited, another thread will be started eventually.
-                synchronized (running){
+                synchronized (runLock){
                     leaseChecker = null;
-                    running = Boolean.FALSE;               
+                    running = false;               
                 }
             }
 	}

Reply via email to