Github user lvfangmin commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/684#discussion_r238788174 --- Diff: zookeeper-server/src/main/java/org/apache/zookeeper/server/NIOServerCnxn.java --- @@ -235,10 +237,12 @@ void handleWrite(SelectionKey k) throws IOException, CloseRequestException { if (bb == ServerCnxnFactory.closeConn) { throw new CloseRequestException("close requested"); } + if (bb == packetSentinel) { --- End diff -- Since we separate the response into multiple pieces, length, header, data, we need a way to tell if it's the end of a response or not, and the sentinel is added for this purpose.
---