Commit 1129baf3 authored by Michi Mutsuzaki's avatar Michi Mutsuzaki
Browse files

ZOOKEEPER-1839. Deadlock in NettyServerCnxn (Rakesh R via michim)


git-svn-id: https://svn.apache.org/repos/asf/zookeeper/branches/branch-3.4@1551112 13f79535-47bb-0310-9956-ffa450edef68
parent ea7a2c5e
......@@ -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
......
......@@ -108,13 +108,13 @@ public class NettyServerCnxn extends ServerCnxn {
.getRemoteAddress()).getAddress());
s.remove(this);
}
}
if (channel.isOpen()) {
channel.close();
}
factory.unregisterConnection(this);
}
}
@Override
public long getSessionId() {
......
......@@ -260,9 +260,12 @@ public class NettyServerCnxnFactory extends ServerCnxnFactory {
LOG.debug("closeAll()");
}
NettyServerCnxn[] allCnxns = null;
synchronized (cnxns) {
allCnxns = cnxns.toArray(new NettyServerCnxn[cnxns.size()]);
}
// got to clear all the connections that we have in the selector
for (NettyServerCnxn cnxn : cnxns.toArray(new NettyServerCnxn[cnxns.size()])) {
for (NettyServerCnxn cnxn : allCnxns) {
try {
cnxn.close();
} catch (Exception e) {
......@@ -270,10 +273,9 @@ public class NettyServerCnxnFactory extends ServerCnxnFactory {
+ 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,9 +284,11 @@ public class NettyServerCnxnFactory extends ServerCnxnFactory {
if (LOG.isDebugEnabled()) {
LOG.debug("closeSession sessionid:0x" + sessionId);
}
NettyServerCnxn[] allCnxns = null;
synchronized (cnxns) {
for (NettyServerCnxn cnxn : cnxns.toArray(new NettyServerCnxn[cnxns.size()])) {
allCnxns = cnxns.toArray(new NettyServerCnxn[cnxns.size()]);
}
for (NettyServerCnxn cnxn : allCnxns) {
if (cnxn.getSessionId() == sessionId) {
try {
cnxn.close();
......@@ -295,7 +299,6 @@ public class NettyServerCnxnFactory extends ServerCnxnFactory {
}
}
}
}
@Override
public void configure(InetSocketAddress addr, int maxClientCnxns)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment