You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2016/01/19 19:02:26 UTC

[2/3] activemq-artemis git commit: ARTEMIS-350 Small improvement on the replication stop

ARTEMIS-350 Small improvement on the replication stop


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/68faa1d2
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/68faa1d2
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/68faa1d2

Branch: refs/heads/master
Commit: 68faa1d25245c45c15cf79cdc0ef25e0881baa61
Parents: b7f0d14
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Jan 19 11:14:16 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Jan 19 11:20:47 2016 -0500

----------------------------------------------------------------------
 .../core/replication/ReplicationManager.java        | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/68faa1d2/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java
index 74f9906..3c2d236 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java
@@ -263,14 +263,17 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene
       if (!started) {
          return;
       }
-      replicatingChannel.getConnection().getTransportConnection().fireReady(true);
-      latch.setCount(0);
+
+      enabled = false;
+
+      // This is to avoid the write holding a lock while we are trying to close it
+      if (replicatingChannel != null) {
+         replicatingChannel.close();
+         replicatingChannel.getConnection().getTransportConnection().fireReady(true);
+         latch.setCount(0);
+      }
 
       synchronized (replicationLock) {
-         enabled = false;
-         if (replicatingChannel != null) {
-            replicatingChannel.close();
-         }
          clearReplicationTokens();
       }
 
@@ -278,7 +281,6 @@ public final class ReplicationManager implements ActiveMQComponent, ReadyListene
       if (toStop != null) {
          toStop.removeFailureListener(failureListener);
       }
-
       remotingConnection = null;
       started = false;
    }