activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject activemq-artemis git commit: ARTEMIS-892 - add lock to tick method
Date Fri, 16 Dec 2016 19:17:08 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/1.x 99a62f75f -> 6d022d035


ARTEMIS-892 - add lock to tick method

https://issues.apache.org/jira/browse/ARTEMIS-892
(cherry picked from commit 198143edd082325801cbe8b1d8aa885a3ad47f35)


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

Branch: refs/heads/1.x
Commit: 6d022d035e2084e427be8157acc25d17d113d250
Parents: 99a62f7
Author: Andy Taylor <andy.tayls67@gmail.com>
Authored: Fri Dec 16 12:11:40 2016 +0000
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Fri Dec 16 14:16:57 2016 -0500

----------------------------------------------------------------------
 .../amqp/proton/handler/ProtonHandler.java      | 26 +++++++++++---------
 1 file changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6d022d03/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
index 945d01e..71cf4a3 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java
@@ -91,22 +91,24 @@ public class ProtonHandler extends ProtonInitializable {
    }
 
    public long tick(boolean firstTick) {
-      if (!firstTick) {
-         try {
-            if (connection.getLocalState() != EndpointState.CLOSED) {
-               long rescheduleAt = transport.tick(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()));
-               if (transport.isClosed()) {
-                  throw new IllegalStateException("Channel was inactive for to long");
+      synchronized (lock) {
+         if (!firstTick) {
+            try {
+               if (connection.getLocalState() != EndpointState.CLOSED) {
+                  long rescheduleAt = transport.tick(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()));
+                  if (transport.isClosed()) {
+                     throw new IllegalStateException("Channel was inactive for to long");
+                  }
+                  return rescheduleAt;
                }
-               return rescheduleAt;
+            } catch (Exception e) {
+               transport.close();
+               connection.setCondition(new ErrorCondition());
             }
-         } catch (Exception e) {
-            transport.close();
-            connection.setCondition(new ErrorCondition());
+            return 0;
          }
-         return 0;
+         return transport.tick(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()));
       }
-      return transport.tick(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()));
    }
 
    public int capacity() {


Mime
View raw message