[jboss-remoting-commits] JBoss Remoting SVN: r6083 - remoting2/branches/2.x/src/main/org/jboss/remoting.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Tue Sep 7 13:38:21 EDT 2010


Author: ron.sigal at jboss.com
Date: 2010-09-07 13:38:21 -0400 (Tue, 07 Sep 2010)
New Revision: 6083

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

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java	2010-09-07 17:18:29 UTC (rev 6082)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/Client.java	2010-09-07 17:38:21 UTC (rev 6083)
@@ -2018,7 +2018,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