You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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>
Closesapache#1000 from xoiss/ZOOKEEPER-2894
0 commit comments