Author: bershath27
Date: 2012-02-13 03:06:16 -0500 (Mon, 13 Feb 2012)
New Revision: 6432
Modified:
remoting2/branches/2.5.4.SP3_JBREM-1297/src/main/org/jboss/remoting/ConnectionValidator.java
Log:
JBPAPP-8030
Modified:
remoting2/branches/2.5.4.SP3_JBREM-1297/src/main/org/jboss/remoting/ConnectionValidator.java
===================================================================
---
remoting2/branches/2.5.4.SP3_JBREM-1297/src/main/org/jboss/remoting/ConnectionValidator.java 2012-02-13
08:05:37 UTC (rev 6431)
+++
remoting2/branches/2.5.4.SP3_JBREM-1297/src/main/org/jboss/remoting/ConnectionValidator.java 2012-02-13
08:06:16 UTC (rev 6432)
@@ -1077,8 +1077,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);
+ if (trace) log.trace(ConnectionValidator.this + "
disconnectTimeout: " + disconnectTimeout);
+
+ // 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