activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [5/6] activemq-artemis git commit: ARTEMIS-474 Avoiding one lock around the readyListener call tree and fixing ReplicationManager / NettyConnection deadlock
Date Fri, 15 Apr 2016 01:14:51 GMT
ARTEMIS-474 Avoiding one lock around the readyListener call tree and fixing ReplicationManager
/ NettyConnection deadlock


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

Branch: refs/heads/master
Commit: 3ecd8b7c44934838ad1176b7ac240b7b3ef8f957
Parents: 2e89455
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Wed Apr 6 12:58:50 2016 -0400
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Thu Apr 14 18:55:01 2016 -0400

----------------------------------------------------------------------
 .../remoting/impl/netty/NettyConnection.java    | 42 ++++++++++++++------
 1 file changed, 29 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3ecd8b7c/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
index 3f10227..6947883 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
@@ -106,25 +106,41 @@ public class NettyConnection implements Connection {
    }
 
    @Override
-   public synchronized boolean isWritable(ReadyListener callback) {
-      if (!ready) {
-         readyListeners.push(callback);
-      }
+   public boolean isWritable(ReadyListener callback) {
+      synchronized (readyListeners) {
+         if (!ready) {
+            readyListeners.push(callback);
+         }
 
-      return ready;
+         return ready;
+      }
    }
 
    @Override
-   public synchronized void fireReady(final boolean ready) {
-      this.ready = ready;
-
-      if (ready) {
-         for (;;) {
-            ReadyListener readyListener = readyListeners.poll();
-            if (readyListener == null) {
-               return;
+   public void fireReady(final boolean ready) {
+      LinkedList<ReadyListener> readyToCall = null;
+      synchronized (readyListeners) {
+         this.ready = ready;
+
+         if (ready) {
+            for (;;) {
+               ReadyListener readyListener = readyListeners.poll();
+               if (readyListener == null) {
+                  break;
+               }
+
+
+               if (readyToCall == null) {
+                  readyToCall = new LinkedList<>();
+               }
+
+               readyToCall.add(readyListener);
             }
+         }
+      }
 
+      if (readyToCall != null) {
+         for (ReadyListener readyListener : readyToCall) {
             try {
                readyListener.readyForWriting();
             }


Mime
View raw message