zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mic...@apache.org
Subject svn commit: r1551112 - in /zookeeper/branches/branch-3.4: CHANGES.txt src/java/main/org/apache/zookeeper/server/NettyServerCnxn.java src/java/main/org/apache/zookeeper/server/NettyServerCnxnFactory.java
Date Mon, 16 Dec 2013 04:20:41 GMT
Author: michim
Date: Mon Dec 16 04:20:40 2013
New Revision: 1551112

URL: http://svn.apache.org/r1551112
Log:
ZOOKEEPER-1839. Deadlock in NettyServerCnxn (Rakesh R via michim)

Modified:
    zookeeper/branches/branch-3.4/CHANGES.txt
    zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/NettyServerCnxn.java
    zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/NettyServerCnxnFactory.java

Modified: zookeeper/branches/branch-3.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1551112&r1=1551111&r2=1551112&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.4/CHANGES.txt Mon Dec 16 04:20:40 2013
@@ -186,6 +186,8 @@ BUGFIXES:
   ZOOKEEPER-1837. Fix JMXEnv checks (potential race conditions)
   (Germán Blanco via fpj)
 
+  ZOOKEEPER-1839. Deadlock in NettyServerCnxn (Rakesh R via michim)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1564. Allow JUnit test build with IBM Java

Modified: zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/NettyServerCnxn.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/NettyServerCnxn.java?rev=1551112&r1=1551111&r2=1551112&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/NettyServerCnxn.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/NettyServerCnxn.java
Mon Dec 16 04:20:40 2013
@@ -108,12 +108,12 @@ public class NettyServerCnxn extends Ser
                             .getRemoteAddress()).getAddress());
                 s.remove(this);
             }
-    
-            if (channel.isOpen()) {
-                channel.close();
-            }
-            factory.unregisterConnection(this);
         }
+
+        if (channel.isOpen()) {
+            channel.close();
+        }
+        factory.unregisterConnection(this);
     }
 
     @Override

Modified: zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/NettyServerCnxnFactory.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/NettyServerCnxnFactory.java?rev=1551112&r1=1551111&r2=1551112&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/NettyServerCnxnFactory.java
(original)
+++ zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/server/NettyServerCnxnFactory.java
Mon Dec 16 04:20:40 2013
@@ -260,20 +260,22 @@ public class NettyServerCnxnFactory exte
             LOG.debug("closeAll()");
         }
 
+        NettyServerCnxn[] allCnxns = null;
         synchronized (cnxns) {
-            // got to clear all the connections that we have in the selector
-            for (NettyServerCnxn cnxn : cnxns.toArray(new NettyServerCnxn[cnxns.size()]))
{
-                try {
-                    cnxn.close();
-                } catch (Exception e) {
-                    LOG.warn("Ignoring exception closing cnxn sessionid 0x"
-                            + Long.toHexString(cnxn.getSessionId()), e);
-                }
+            allCnxns = cnxns.toArray(new NettyServerCnxn[cnxns.size()]);
+        }
+        // got to clear all the connections that we have in the selector
+        for (NettyServerCnxn cnxn : allCnxns) {
+            try {
+                cnxn.close();
+            } catch (Exception e) {
+                LOG.warn("Ignoring exception closing cnxn sessionid 0x"
+                                + Long.toHexString(cnxn.getSessionId()), e);
             }
         }
         if (LOG.isDebugEnabled()) {
-            LOG.debug("allChannels size:" + allChannels.size()
-                    + " cnxns size:" + cnxns.size());
+            LOG.debug("allChannels size:" + allChannels.size() + " cnxns size:"
+                    + allCnxns.length);
         }
     }
 
@@ -282,17 +284,18 @@ public class NettyServerCnxnFactory exte
         if (LOG.isDebugEnabled()) {
             LOG.debug("closeSession sessionid:0x" + sessionId);
         }
-
+        NettyServerCnxn[] allCnxns = null;
         synchronized (cnxns) {
-            for (NettyServerCnxn cnxn : cnxns.toArray(new NettyServerCnxn[cnxns.size()]))
{
-                if (cnxn.getSessionId() == sessionId) {
-                    try {
-                        cnxn.close();
-                    } catch (Exception e) {
-                        LOG.warn("exception during session close", e);
-                    }
-                    break;
+            allCnxns = cnxns.toArray(new NettyServerCnxn[cnxns.size()]);
+        }
+        for (NettyServerCnxn cnxn : allCnxns) {
+            if (cnxn.getSessionId() == sessionId) {
+                try {
+                    cnxn.close();
+                } catch (Exception e) {
+                    LOG.warn("exception during session close", e);
                 }
+                break;
             }
         }
     }



Mime
View raw message