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,12 +108,12 @@ public class NettyServerCnxn extends ServerCnxn {
.getRemoteAddress()).getAddress());
s.remove(this);
}
if (channel.isOpen()) {
channel.close();
}
factory.unregisterConnection(this);
}
if (channel.isOpen()) {
channel.close();
}
factory.unregisterConnection(this);
}
@Override
......
......@@ -260,20 +260,22 @@ public class NettyServerCnxnFactory extends ServerCnxnFactory {
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 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()])) {
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;
}
}
}
......
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