Skip to content

Commit d173526

Browse files
committed
destruct callbacks (and their closures) to ensure there are no reference cycles when destructing the consumer. This solves a hang in rd_kafka_destroy
1 parent deff8b1 commit d173526

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: src/consumer.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ Consumer::Consumer(Configuration config)
6666

6767
Consumer::~Consumer() {
6868
try {
69+
// make sure to destroy the function closures. in case they hold kafka
70+
// objects, they will need to be destroyed before we destroy the handle
71+
assignment_callback_ = nullptr;
72+
revocation_callback_ = nullptr;
73+
rebalance_error_callback_ = nullptr;
6974
close();
7075
}
7176
catch (const Exception&) {

0 commit comments

Comments
 (0)