[jboss-cvs] JBoss Messaging SVN: r8612 - branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/postoffice.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 18 07:41:51 EDT 2013
Author: gaohoward
Date: 2013-09-18 07:41:51 -0400 (Wed, 18 Sep 2013)
New Revision: 8612
Modified:
branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java
Log:
JBMESSAGING-1947 Deadlock may happen when JBM shuts down a JGroups channel
Modified: branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java
===================================================================
--- branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java 2013-09-18 07:48:09 UTC (rev 8611)
+++ branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/postoffice/MessagingPostOffice.java 2013-09-18 11:41:51 UTC (rev 8612)
@@ -4252,6 +4252,7 @@
private class StateMonitor extends Thread
{
private boolean working = true;
+ private boolean stoppingNode = false;
public StateMonitor()
{
@@ -4266,50 +4267,73 @@
}
}
- public synchronized void stopJBMNodeForRecovery()
+ public void stopJBMNodeForRecovery()
{
- disableViewUpdate();
- serverPeer.stopJBMNodeForRecovery();
+ synchronized(this)
+ {
+ if (stoppingNode) return;
+ stoppingNode = true;
+ }
+
+ //using a new thread.
+ new Thread(new Runnable() {
+
+ public void run()
+ {
+ disableViewUpdate();
+ serverPeer.stopJBMNodeForRecovery();
+ }
+
+ }).start();
}
public synchronized void run()
{
- do
+ boolean shutdownNode = false;
+ synchronized(this)
{
- boolean timeStampDone = false;
- try
+ do
{
- timeStampDone = refreshNodeState();
-
- if (timeStampDone)
+ boolean timeStampDone = false;
+ try
{
- processClusterState();
- }
- else if (clusterState.isQuarantined(thisNodeID) || iAmAlone())
- {
- log.error("I'm orphaned and now I can't tell others that I'm alive. Shutdown node: " + thisNodeID);
- stopJBMNodeForRecovery();
- working = false;
- nodeStateRefreshInterval = 1; //let the thread quite quickly.
- }
+ timeStampDone = refreshNodeState();
- try
- {
- wait(nodeStateRefreshInterval);
+ if (timeStampDone)
+ {
+ processClusterState();
+ }
+ else if (clusterState.isQuarantined(thisNodeID) || iAmAlone())
+ {
+ log.error("I'm orphaned and now I can't tell others that I'm alive. Shutdown node: " + thisNodeID);
+ shutdownNode = true;
+ working = false;
+ break;
+ }
+
+ try
+ {
+ wait(nodeStateRefreshInterval);
+ }
+ catch (InterruptedException e)
+ {
+ }
}
- catch (InterruptedException e)
+ catch (Exception e)
{
+ log.error("Error refreshing state of node: " + thisNodeID, e);
}
- }
- catch (Exception e)
- {
- log.error("Error refreshing state of node: " + thisNodeID, e);
- }
- } while (working);
- log.debug("Stop monitoring the stats at node " + thisNodeID);
- }
+ } while (working);
+ log.debug("Stop monitoring the stats at node " + thisNodeID);
+ }
+ if (shutdownNode)
+ {
+ stopJBMNodeForRecovery();
+ }
+ }
+
public synchronized void shutdown()
{
working = false;
More information about the jboss-cvs-commits
mailing list