Author: clebert.suconic(a)jboss.com
Date: 2011-08-09 13:43:09 -0400 (Tue, 09 Aug 2011)
New Revision: 11170
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/Topology.java
Log:
fixing deadlock after my fixes
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/Topology.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/Topology.java 2011-08-09
13:40:37 UTC (rev 11169)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/client/impl/Topology.java 2011-08-09
17:43:09 UTC (rev 11170)
@@ -172,23 +172,32 @@
if (replaced)
{
- ArrayList<ClusterTopologyListener> copy = copyListeners();
- for (ClusterTopologyListener listener : copy)
- {
- if (Topology.log.isTraceEnabled())
+ final ArrayList<ClusterTopologyListener> copy = copyListeners();
+
+
+ // Has to use a different thread otherwise we may get dead locks case the remove
is coming from the channel
+ execute(new Runnable(){
+ public void run()
{
- Topology.log.trace(this + " informing " + listener + "
about node up = " + nodeId);
- }
+ for (ClusterTopologyListener listener : copy)
+ {
+ if (Topology.log.isTraceEnabled())
+ {
+ Topology.log.trace(this + " informing " + listener +
" about node up = " + nodeId);
+ }
- try
- {
- listener.nodeUP(nodeId, member.getConnector(), last);
+ try
+ {
+ listener.nodeUP(nodeId, member.getConnector(), last);
+ }
+ catch (Throwable e)
+ {
+ log.warn (e.getMessage(), e);
+ }
+ }
}
- catch (Throwable e)
- {
- log.warn (e.getMessage(), e);
- }
- }
+ });
+
}
return replaced;
@@ -230,16 +239,22 @@
if (member != null)
{
- ArrayList<ClusterTopologyListener> copy = copyListeners();
+ final ArrayList<ClusterTopologyListener> copy = copyListeners();
- for (ClusterTopologyListener listener : copy)
- {
- if (Topology.log.isTraceEnabled())
+ // Has to use a different thread otherwise we may get dead locks case the remove
is coming from the channel
+ execute(new Runnable(){
+ public void run()
{
- Topology.log.trace(this + " informing " + listener + "
about node down = " + nodeId);
+ for (ClusterTopologyListener listener : copy)
+ {
+ if (Topology.log.isTraceEnabled())
+ {
+ Topology.log.trace(this + " informing " + listener +
" about node down = " + nodeId);
+ }
+ listener.nodeDown(nodeId);
+ }
}
- listener.nodeDown(nodeId);
- }
+ });
}
return member != null;
}
@@ -379,6 +394,19 @@
}
return null;
}
+
+ private void execute(Runnable runnable)
+ {
+ if (executor != null)
+ {
+ log.debug(this + " is running runnable without an executor");
+ executor.execute(runnable);
+ }
+ else
+ {
+ runnable.run();
+ }
+ }
/* (non-Javadoc)
* @see java.lang.Object#toString()
Show replies by date