Author: ron.sigal(a)jboss.com
Date: 2011-08-26 23:28:38 -0400 (Fri, 26 Aug 2011)
New Revision: 6403
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/ConnectionValidator.java
Log:
JBREM-1297: Synchronize on Client.connectionValidatorLock while calling
MicroRemoteClientInvoker.terminateLease().
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/ConnectionValidator.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/ConnectionValidator.java 2011-08-27
03:19:11 UTC (rev 6402)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/ConnectionValidator.java 2011-08-27
03:28:38 UTC (rev 6403)
@@ -1049,7 +1049,35 @@
log.debug(ConnectionValidator.this + " shutting down lease pinger:
" + leasePinger);
int disconnectTimeout = (failureDisconnectTimeout == -1) ?
client.getDisconnectTimeout() : failureDisconnectTimeout;
if (trace) log.trace(ConnectionValidator.this + "
disconnectTimeout: " + disconnectTimeout);
- sharedInvoker.terminateLease(null, disconnectTimeout, leasePinger);
+
+ // Synchronizing on Client.connectionValidatorLock to prevent a
deadlock:
+ //
+ // 1. a. This method calls MicroRemoteClientInvoker.terminateLease()
+ // b. MicroRemoteClientInvoker.terminateLease() synchronizes on
MicroRemoteClientInvoker.clientLeaseLock
+ // c. MicroRemoteClientInvoker.terminateLease() calls
LeasePinger.stopPing()
+ // d. LeasePinger.stopPing() calls Client.notifyListeners()
+ // e. Client.notifyListeners() synchronizes on
Client.connectionValidatorLock
+ //
+ // 2. a. Client.connect() calls Client.setupClientLease()
+ // b. Client.setupClientLease() synchronizes on
Client.connectionValidatorLock
+ // c. Client.setupClientLease() calls
MicroRemoteClientInvoker.establishLease()
+ // d. MicroRemoteClientInvoker.establishLease() synchronizes on
MicroRemoteClientInvoker.clientLeaseLock
+ // e. MicroRemoteClientInvoker.establishLease() calls
Client.addConnectionListener()
+ // f. Client.addConnectionListener() synchronizes on
Client.connectionValidatorLock
+ //
+ // 3. a. Client.addConnectionListener() synchronizes on
Client.connectionValidatorLock
+ // b. Client.addConnectionListener() calls new
ConnectionValidator()
+ // c. new ConnectionValidator() calls
MicroRemoteClientInvoker.getLeasePinger()
+ // d. MicroRemoteClientInvoker.getLeasePinger() synchronizes on
MicroRemoteClientInvoker.clientLeaseLock
+ //
+ // By synchronizing on connectionValidatorLock here, we assure that all
sequences acquire
+ // Client.connectionValidatorLock first and then acquire
MicroRemoteClientInvoker.clientLeaseLock.
+ //
+ // See JBREM-1242 and JBREM-1297.
+ synchronized (Client.getConnectionValidatorLock())
+ {
+ sharedInvoker.terminateLease(null, disconnectTimeout, leasePinger);
+ }
}
else
{
Show replies by date