Author: raggz
Date: 2011-11-30 15:54:32 -0500 (Wed, 30 Nov 2011)
New Revision: 6421
Modified:
remoting2/branches/2.5.4.SP2_JBREM-1297/
remoting2/branches/2.5.4.SP2_JBREM-1297/src/main/org/jboss/remoting/ConnectionValidator.java
Log:
JBPAPP-7631; Back port JBREM-1297 - part2.
Property changes on: remoting2/branches/2.5.4.SP2_JBREM-1297
___________________________________________________________________
Modified: svn:mergeinfo
- /remoting2/branches/2.x:6401
+ /remoting2/branches/2.x:6401-6402
Modified:
remoting2/branches/2.5.4.SP2_JBREM-1297/src/main/org/jboss/remoting/ConnectionValidator.java
===================================================================
---
remoting2/branches/2.5.4.SP2_JBREM-1297/src/main/org/jboss/remoting/ConnectionValidator.java 2011-11-30
20:52:18 UTC (rev 6420)
+++
remoting2/branches/2.5.4.SP2_JBREM-1297/src/main/org/jboss/remoting/ConnectionValidator.java 2011-11-30
20:54:32 UTC (rev 6421)
@@ -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