You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mh...@apache.org on 2019/08/12 15:31:25 UTC

[asterixdb] branch master updated: [NO ISSUE][NET] Ensure Handshake Connections List is Thread-Safe

This is an automated email from the ASF dual-hosted git repository.

mhubail pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 783f7b3  [NO ISSUE][NET] Ensure Handshake Connections List is Thread-Safe
783f7b3 is described below

commit 783f7b3cc2dd14b1f1a91f131504244368a8234d
Author: Murtadha Hubail <mh...@apache.org>
AuthorDate: Fri Aug 9 22:46:40 2019 -0700

    [NO ISSUE][NET] Ensure Handshake Connections List is Thread-Safe
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    - Ensure the list of connections that completed their asynchronous
      SSL handshake is accessed in thread-safe manner.
    
    Change-Id: Ibfd4fc569b59f39d730ef04f5d69b23d91713ed7
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/3523
    Reviewed-by: Murtadha Hubail <mh...@apache.org>
    Contrib: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Till Westmann <ti...@apache.org>
---
 .../hyracks/net/protocols/tcp/TCPEndpoint.java     | 26 +++++++++++++---------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/hyracks-fullstack/hyracks/hyracks-net/src/main/java/org/apache/hyracks/net/protocols/tcp/TCPEndpoint.java b/hyracks-fullstack/hyracks/hyracks-net/src/main/java/org/apache/hyracks/net/protocols/tcp/TCPEndpoint.java
index faec871..b75e3c6 100644
--- a/hyracks-fullstack/hyracks/hyracks-net/src/main/java/org/apache/hyracks/net/protocols/tcp/TCPEndpoint.java
+++ b/hyracks-fullstack/hyracks/hyracks-net/src/main/java/org/apache/hyracks/net/protocols/tcp/TCPEndpoint.java
@@ -176,11 +176,13 @@ public class TCPEndpoint {
                         }
                         workingIncomingConnections.clear();
                     }
-                    if (!handshakeCompletedConnections.isEmpty()) {
-                        for (final PendingHandshakeConnection conn : handshakeCompletedConnections) {
-                            handshakeCompleted(conn);
+                    synchronized (handshakeCompletedConnections) {
+                        if (!handshakeCompletedConnections.isEmpty()) {
+                            for (final PendingHandshakeConnection conn : handshakeCompletedConnections) {
+                                handshakeCompleted(conn);
+                            }
+                            handshakeCompletedConnections.clear();
                         }
-                        handshakeCompletedConnections.clear();
                     }
                     if (n > 0) {
                         Iterator<SelectionKey> i = selector.selectedKeys().iterator();
@@ -297,8 +299,7 @@ public class TCPEndpoint {
             if (socketChannel.requiresHandshake()) {
                 asyncHandshake(conn);
             } else {
-                conn.handshakeSuccess = true;
-                handshakeCompletedConnections.add(conn);
+                handshakeCompleted(true, conn);
             }
         }
 
@@ -308,8 +309,7 @@ public class TCPEndpoint {
             if (socketChannel.requiresHandshake()) {
                 asyncHandshake(conn);
             } else {
-                conn.handshakeSuccess = true;
-                handshakeCompletedConnections.add(conn);
+                handshakeCompleted(true, conn);
             }
         }
 
@@ -319,11 +319,17 @@ public class TCPEndpoint {
         }
 
         private void handleHandshakeCompletion(Boolean handshakeSuccess, PendingHandshakeConnection conn) {
-            conn.handshakeSuccess = handshakeSuccess;
-            handshakeCompletedConnections.add(conn);
+            handshakeCompleted(handshakeSuccess, conn);
             selector.wakeup();
         }
 
+        private void handshakeCompleted(Boolean handshakeSuccess, PendingHandshakeConnection conn) {
+            conn.handshakeSuccess = handshakeSuccess;
+            synchronized (handshakeCompletedConnections) {
+                handshakeCompletedConnections.add(conn);
+            }
+        }
+
         private void connectionEstablished(TCPConnection connection) {
             synchronized (connectionListener) {
                 connectionListener.connectionEstablished(connection);