Author: ron.sigal(a)jboss.com
Date: 2011-08-26 23:19:11 -0400 (Fri, 26 Aug 2011)
New Revision: 6402
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java
Log:
JBREM-1297: Synchronize on Client.connectionValidatorLock while calling
MicroRemoteClientInvoker.terminateLease().
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java 2011-08-27
03:18:00 UTC (rev 6401)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java 2011-08-27
03:19:11 UTC (rev 6402)
@@ -1078,7 +1078,36 @@
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