Author: clebert.suconic(a)jboss.com
Date: 2011-04-29 13:04:02 -0400 (Fri, 29 Apr 2011)
New Revision: 10581
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
Log:
Fixing deadlock caused by my previous fix - JBPAPP-6420
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java 2011-04-29
16:19:47 UTC (rev 10580)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/ClientSessionFactoryImpl.java 2011-04-29
17:04:02 UTC (rev 10581)
@@ -17,6 +17,7 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -358,15 +359,12 @@
// inconsistencies
public void removeSession(final ClientSessionInternal session, boolean failingOver)
{
- synchronized (createSessionLock)
+ synchronized (sessions)
{
- synchronized (failoverLock)
- {
- sessions.remove(session);
- }
+ sessions.remove(session);
}
}
-
+
public void connectionReadyForWrites(final Object connectionID, final boolean ready)
{
}
@@ -413,8 +411,13 @@
{
synchronized (failoverLock)
{
+ HashSet<ClientSession> sessionsToClose;
+ synchronized (sessions)
+ {
+ sessionsToClose = new HashSet<ClientSession>(sessions);
+ }
// work on a copied set. the session will be removed from sessions when
session.close() is called
- for (ClientSession session : new HashSet<ClientSession>(sessions))
+ for (ClientSession session : sessionsToClose)
{
try
{
@@ -581,7 +584,10 @@
if (connection == null)
{
- sessionsToClose = new HashSet<ClientSessionInternal>(sessions);
+ synchronized (sessions)
+ {
+ sessionsToClose = new HashSet<ClientSessionInternal>(sessions);
+ }
callFailureListeners(me, true, false);
}
}
@@ -729,7 +735,10 @@
sessionChannel,
orderedExecutorFactory.getExecutor());
- sessions.add(session);
+ synchronized (sessions)
+ {
+ sessions.add(session);
+ }
ChannelHandler handler = new ClientSessionPacketHandler(session,
sessionChannel);
@@ -839,8 +848,14 @@
connection.setFailureListeners(newListeners);
- for (ClientSessionInternal session : sessions)
+ HashSet<ClientSessionInternal> sessionsToFailover;
+ synchronized (sessions)
{
+ sessionsToFailover = new HashSet<ClientSessionInternal>(sessions);
+ }
+
+ for (ClientSessionInternal session : sessionsToFailover)
+ {
session.handleFailover(connection);
}
}
Show replies by date