[jboss-remoting-commits] JBoss Remoting SVN: r6098 - remoting2/branches/2.2.3-SP2_JBREM-1242/src/main/org/jboss/remoting.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Tue Sep 7 16:55:44 EDT 2010


Author: jbertram at redhat.com
Date: 2010-09-07 16:55:43 -0400 (Tue, 07 Sep 2010)
New Revision: 6098

Modified:
   remoting2/branches/2.2.3-SP2_JBREM-1242/src/main/org/jboss/remoting/Client.java
Log:
JBPAPP-5030

Modified: remoting2/branches/2.2.3-SP2_JBREM-1242/src/main/org/jboss/remoting/Client.java
===================================================================
--- remoting2/branches/2.2.3-SP2_JBREM-1242/src/main/org/jboss/remoting/Client.java	2010-09-07 20:33:01 UTC (rev 6097)
+++ remoting2/branches/2.2.3-SP2_JBREM-1242/src/main/org/jboss/remoting/Client.java	2010-09-07 20:55:43 UTC (rev 6098)
@@ -1919,7 +1919,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