ZOOKEEPER-3937: C client: avoid out-of-order packets during SASL negotiation

This patch prevents SASL-enabled C clients from sending request packets for as long as the SASL negociation is not complete.

"Ideally," applications should wait for `ZOO_CONNECTED_STATE` or `ZOO_READONLY_STATE` events before issuing requests, but this is not what happens in the wild.

Without this patch, it was easy to cause a desynchronization by creating a handle and blasting requests right away.  (The added test simply avoids doing a `ctx.waitForConnected()`.)

Author: Damien Diederen <dd@crosstwine.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes #1457 from ztzg/ZOOKEEPER-3937-c-client-out-of-order-packets
2 files changed
tree: 15d1a5c307b45286d842fc1b3ffe4de35dc9f479
  1. bin/
  2. conf/
  3. dev/
  4. tools/
  5. zookeeper-assembly/
  6. zookeeper-client/
  7. zookeeper-compatibility-tests/
  8. zookeeper-contrib/
  9. zookeeper-docs/
  10. zookeeper-it/
  11. zookeeper-jute/
  12. zookeeper-metrics-providers/
  13. zookeeper-recipes/
  14. zookeeper-server/
  15. .gitattributes
  16. .gitignore
  17. .travis.yml
  18. checkstyle-simple.xml
  19. checkstyle-strict.xml
  20. checkstyleSuppressions.xml
  21. excludeFindBugsFilter.xml
  22. Jenkinsfile
  23. Jenkinsfile-PreCommit
  24. LICENSE.txt
  25. NOTICE.txt
  26. owaspSuppressions.xml
  27. pom.xml
  28. README.md
  29. README_packaging.md
  30. zk-merge-pr.py
README.md

Apache ZooKeeper Build Status Maven Central License

alt text

For the latest information about Apache ZooKeeper, please visit our website at:

http://zookeeper.apache.org/

and our wiki, at:

https://cwiki.apache.org/confluence/display/ZOOKEEPER


Packaging/release artifacts

Either downloaded from https://zookeeper.apache.org/releases.html or found in zookeeper-assembly/target directory after building the project with maven.

apache-zookeeper-[version].tar.gz

    Contains all the source files which can be built by running:
    mvn clean install

    To generate an aggregated apidocs for zookeeper-server and zookeeper-jute:
    mvn javadoc:aggregate
    (generated files will be at target/site/apidocs)

apache-zookeeper-[version]-bin.tar.gz

    Contains all the jar files required to run ZooKeeper
    Full documentation can also be found in the docs folder

As of version 3.5.5, the parent, zookeeper and zookeeper-jute artifacts are deployed to the central repository after the release is voted on and approved by the Apache ZooKeeper PMC:

https://repo1.maven.org/maven2/org/apache/zookeeper/zookeeper/

Java 8

If you are going to compile with Java 1.8, you should use a recent release at u211 or above.

Contributing

We always welcome new contributors to the project! See How to Contribute for details on how to submit patch through pull request and our contribution workflow.