[jboss-remoting-commits] JBoss Remoting SVN: r6082 - remoting2/branches/2.2/src/main/org/jboss/remoting.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Tue Sep 7 13:18:29 EDT 2010


Author: ron.sigal at jboss.com
Date: 2010-09-07 13:18:29 -0400 (Tue, 07 Sep 2010)
New Revision: 6082

Modified:
   remoting2/branches/2.2/src/main/org/jboss/remoting/Client.java
Log:
JBREM-1242: In setupClientLease(), synchronized call to invoker.establishLease() on connectionValidatorLock.

Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/Client.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/Client.java	2010-09-07 13:27:25 UTC (rev 6081)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/Client.java	2010-09-07 17:18:29 UTC (rev 6082)
@@ -1920,7 +1920,26 @@
             temp.put(CONNECTION_LISTENER, listener);
          }
          if (trace) log.trace(this + " calling MicroRemoteClientInvoker.establishLease()");
-         invoker.establishLease(sessionId, temp, leasePeriod);
+         
+         // Synchronizing on connectionValidatorLock to prevent a deadlock:
+         //
+         // 1. a. This method calls MicroRemoteClientInvoker.establishLease()
+         //    b. MicroRemoteClientInvoker.establishLease() synchronizes on MicroRemoteClientInvoker.clientLeaseLock
+         //       and calls Client.addConnectionListener()
+         //    c. Client.addConnectionListener() synchronizes on Client.connectionValidatorLock
+         //
+         // 2. a. Client.addConnectionListener() synchronizes on Client.connectionValidatorLock and calls
+         //       new ConnectionValidator()
+         //    b. new ConnectionValidator() calls MicroRemoteClientInvoker.getLeasePinger(), which
+         //       synchronizes on MicroRemoteClientInvoker.clientLeaseLock
+         //
+         // By synchronizing on connectionValidatorLock here, we assure that both sequences acquire
+         // Client.connectionValidatorLock first and then acquire MicroRemoteClientInvoker.clientLeaseLock.
+         //
+         synchronized(connectionValidatorLock)
+         {
+            invoker.establishLease(sessionId, temp, leasePeriod);
+         }
       }
       else if (listener != null)
       {



More information about the jboss-remoting-commits mailing list