cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [2/6] git commit: Fix potential socket leak in connectionpool creation patch by Minh Do; reviewed by jbellis for CASSANDRA-6308
Date Wed, 06 Nov 2013 20:34:44 GMT
Fix potential socket leak in connectionpool creation
patch by Minh Do; reviewed by jbellis for CASSANDRA-6308


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

Branch: refs/heads/cassandra-2.0
Commit: 8c2404493a6efc109cd621c02a4de6ef1f1f46aa
Parents: 8e7d728
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Wed Nov 6 12:33:45 2013 -0800
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Wed Nov 6 12:33:45 2013 -0800

----------------------------------------------------------------------
 CHANGES.txt                                             |  1 +
 src/java/org/apache/cassandra/net/MessagingService.java | 12 +++++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/8c240449/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index fd3af68..eab185a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -11,6 +11,7 @@
  * Nodetool gets default JMX port from cassandra-env.sh (CASSANDRA-6273)
  * make calculatePendingRanges asynchronous (CASSANDRA-6244)
  * Remove blocking flushes in gossip thread (CASSANDRA-6297)
+ * Fix potential socket leak in connectionpool creation (CASSANDRA-6308)
 
 
 1.2.11

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8c240449/src/java/org/apache/cassandra/net/MessagingService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/net/MessagingService.java b/src/java/org/apache/cassandra/net/MessagingService.java
index a199e83..7e420cf 100644
--- a/src/java/org/apache/cassandra/net/MessagingService.java
+++ b/src/java/org/apache/cassandra/net/MessagingService.java
@@ -259,7 +259,7 @@ public final class MessagingService implements MessagingServiceMBean
      */
     private final ConcurrentMap<InetAddress, DebuggableThreadPoolExecutor> streamExecutors
= new NonBlockingHashMap<InetAddress, DebuggableThreadPoolExecutor>();
 
-    private final NonBlockingHashMap<InetAddress, OutboundTcpConnectionPool> connectionManagers
= new NonBlockingHashMap<InetAddress, OutboundTcpConnectionPool>();
+    private final ConcurrentMap<InetAddress, OutboundTcpConnectionPool> connectionManagers
= new NonBlockingHashMap<InetAddress, OutboundTcpConnectionPool>();
 
     private static final Logger logger = LoggerFactory.getLogger(MessagingService.class);
     private static final int LOG_DROPPED_INTERVAL_IN_MS = 5000;
@@ -484,11 +484,17 @@ public final class MessagingService implements MessagingServiceMBean
         OutboundTcpConnectionPool cp = connectionManagers.get(to);
         if (cp == null)
         {
-            connectionManagers.putIfAbsent(to, new OutboundTcpConnectionPool(to));
-            cp = connectionManagers.get(to);
+            cp = new OutboundTcpConnectionPool(to);
+            OutboundTcpConnectionPool existingPool = connectionManagers.putIfAbsent(to, cp);
+            if (existingPool != null)
+            {
+                cp.close();
+                cp = existingPool;
+            }
         }
         return cp;
     }
+    
 
     public OutboundTcpConnection getConnection(InetAddress to, MessageOut msg)
     {


Mime
View raw message