From d1756b927e1618fca59a288f4a021c2a040068e7 Mon Sep 17 00:00:00 2001 From: Botond Hejj Date: Fri, 6 Jul 2018 10:43:18 -0400 Subject: [PATCH] ZOOKEEPER-3072: Throttle race condition fix Making the throttle check before passing over the request to the next thread will prevent the possibility of throttling code running after unthrottle --- .../zookeeper/server/ZooKeeperServer.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java b/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java index ff5b3b66a90..d9a93156bbf 100644 --- a/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java +++ b/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java @@ -1123,24 +1123,22 @@ public void processPacket(ServerCnxn cnxn, ByteBuffer incomingBuffer) throws IOE cnxn.disableRecv(); } return; + } else if (h.getType() == OpCode.sasl) { + Record rsp = processSasl(incomingBuffer,cnxn); + ReplyHeader rh = new ReplyHeader(h.getXid(), 0, KeeperException.Code.OK.intValue()); + cnxn.sendResponse(rh,rsp, "response"); // not sure about 3rd arg..what is it? + return; } else { - if (h.getType() == OpCode.sasl) { - Record rsp = processSasl(incomingBuffer,cnxn); - ReplyHeader rh = new ReplyHeader(h.getXid(), 0, KeeperException.Code.OK.intValue()); - cnxn.sendResponse(rh,rsp, "response"); // not sure about 3rd arg..what is it? - return; - } - else { - Request si = new Request(cnxn, cnxn.getSessionId(), h.getXid(), - h.getType(), incomingBuffer, cnxn.getAuthInfo()); - si.setOwner(ServerCnxn.me); - // Always treat packet from the client as a possible - // local request. - setLocalSessionFlag(si); - submitRequest(si); - } + cnxn.incrOutstandingRequests(h); + Request si = new Request(cnxn, cnxn.getSessionId(), h.getXid(), + h.getType(), incomingBuffer, cnxn.getAuthInfo()); + si.setOwner(ServerCnxn.me); + // Always treat packet from the client as a possible + // local request. + setLocalSessionFlag(si); + submitRequest(si); + return; } - cnxn.incrOutstandingRequests(h); } private Record processSasl(ByteBuffer incomingBuffer, ServerCnxn cnxn) throws IOException {