Fix race causing infinite loop if Thrift server is stopped before it starts 
listening

patch by Stefania Alborghetti; reviewed by Joel Knighton for CASSANDRA-12856


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/47f7d9c6
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/47f7d9c6
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/47f7d9c6

Branch: refs/heads/cassandra-2.1
Commit: 47f7d9c6aab694bf956fa2174fe0dd36702e01a6
Parents: bdca25e
Author: Stefania Alborghetti <stefania.alborghe...@datastax.com>
Authored: Tue Jan 3 10:09:52 2017 +0100
Committer: Stefania Alborghetti <stefania.alborghe...@datastax.com>
Committed: Wed Jan 11 07:34:15 2017 +0100

----------------------------------------------------------------------
 CHANGES.txt                                                     | 1 +
 .../org/apache/cassandra/thrift/CustomTThreadPoolServer.java    | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/47f7d9c6/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a99f79a..23fd12a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.17
+ * Fix race causing infinite loop if Thrift server is stopped before it starts 
listening (CASSANDRA-12856)
  * cqlsh copy-from: sort user type fields in csv (CASSANDRA-12959)
  * Fix missed signal when commit log segments are recycled (CASSANDRA-13037)
  * Fix RecoveryManagerTruncateTest (CASSANDRA-12802)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/47f7d9c6/src/java/org/apache/cassandra/thrift/CustomTThreadPoolServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/CustomTThreadPoolServer.java 
b/src/java/org/apache/cassandra/thrift/CustomTThreadPoolServer.java
index 7e67110..905a981 100644
--- a/src/java/org/apache/cassandra/thrift/CustomTThreadPoolServer.java
+++ b/src/java/org/apache/cassandra/thrift/CustomTThreadPoolServer.java
@@ -75,13 +75,15 @@ public class CustomTThreadPoolServer extends TServer
     private final TThreadPoolServer.Args args;
 
     //Track and Limit the number of connected clients
-    private final AtomicInteger activeClients = new AtomicInteger(0);
+    private final AtomicInteger activeClients;
 
 
     public CustomTThreadPoolServer(TThreadPoolServer.Args args, 
ExecutorService executorService) {
         super(args);
         this.executorService = executorService;
+        this.stopped = false;
         this.args = args;
+        this.activeClients = new AtomicInteger(0);
     }
 
     public void serve()
@@ -96,7 +98,6 @@ public class CustomTThreadPoolServer extends TServer
             return;
         }
 
-        stopped = false;
         while (!stopped)
         {
             // block until we are under max clients

Reply via email to