ZOOKEEPER-2894: Memory and completions leak on zookeeper_close

If I call `zookeeper_close()` when the call-stack does not pass through any of zookeeper mechanics (for example, some of completion handler called back by zookeeper) the following happens:
1. If there are requests waiting for responses in `zh.sent_requests` queue, they all are removed from this queue and each of them is "completed" with personal fake response having status `ZCLOSING`. Such fake responses are put into `zh.completions_to_process` queue. It's Ok
2. But then, `zh.completions_to_process` queue is left unhandled. **Neither completion callbacks are called, nor dynamic memory allocated for fake responses is freed**
3. Different structures within `zh` are dismissed and finally `zh` is freed

Consequently we have a tiny **memory leak** and, which is much more important, **completions leak**. I.e. completions are not called at all.

This is not the case if I call `zookeeper_close()` when the call-stack does pass through some of zookeeper mechanics. Here, zookeeper client handles completions properly.

Proposed changes remove this defects.

For more details see: https://issues.apache.org/jira/browse/ZOOKEEPER-2894

Author: Alexander A. Strelets <streletsaa@gmail.com>

Reviewers: Enrico Olivelli <eolivelli@gmail.com>, Michael Han <hanm@apache.org>

Closes #1000 from xoiss/ZOOKEEPER-2894
2 files changed
tree: 4e3d4cdcc9329e79af66de244983d38c0d30cb10
  1. bin/
  2. conf/
  3. src/
  4. zookeeper-client/
  5. zookeeper-contrib/
  6. zookeeper-docs/
  7. zookeeper-it/
  8. zookeeper-jute/
  9. zookeeper-recipes/
  10. zookeeper-server/
  11. .gitattributes
  12. .gitignore
  13. .travis.yml
  14. build.xml
  15. excludeFindBugsFilter.xml
  16. ivy.xml
  17. ivysettings.xml
  18. LICENSE.txt
  19. NOTICE.txt
  20. owaspSuppressions.xml
  21. pom.xml
  22. README.md
  23. README_packaging.txt
  24. source-package.xml
README.md

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

http://zookeeper.apache.org/

and our wiki, at:

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

Full documentation for this release can also be found in docs/index.html


Packaging/release artifacts - Maven

A buildable tarball is located under zookeeper/target/ directory

The artifacts for the modules are uploaded to maven central.

Packaging/release artifacts - Ant

The release artifact contains the following jar file at the toplevel:

zookeeper-.jar - legacy jar file which contains all classes and source files. Prior to version 3.3.0 this was the only jar file available. It has the benefit of having the source included (for debugging purposes) however is also larger as a result

The release artifact contains the following jar files in “dist-maven” directory:

zookeeper-.jar - bin (binary) jar - contains only class (.class) files zookeeper--sources.jar - contains only src (.java) files zookeeper--javadoc.jar - contains only javadoc files

These bin/src/javadoc jars were added specifically to support Maven/Ivy which have the ability to pull these down automatically as part of your build process. The content of the legacy jar and the bin+sources jar are the same.

As of version 3.3.0 bin/sources/javadoc jars contained in dist-maven directory are deployed to the Apache Maven repository after the release has been accepted by Apache: http://people.apache.org/repo/m2-ibiblio-rsync-repository/