BewareMyPower commented on code in PR #537:
URL: https://github.com/apache/pulsar-client-cpp/pull/537#discussion_r2762086912
##########
lib/MultiTopicsConsumerImpl.cc:
##########
@@ -850,17 +850,17 @@ void
MultiTopicsConsumerImpl::getBrokerConsumerStatsAsync(const BrokerConsumerSt
LatchPtr latchPtr =
std::make_shared<Latch>(numberTopicPartitions_->load());
lock.unlock();
- size_t i = 0;
- consumers_.forEachValue([this, &latchPtr, &statsPtr, &i, callback](const
ConsumerImplPtr& consumer) {
- size_t index = i++;
- auto weakSelf = weak_from_this();
- consumer->getBrokerConsumerStatsAsync([this, weakSelf, latchPtr,
statsPtr, index, callback](
- Result result, const
BrokerConsumerStats& stats) {
- auto self = weakSelf.lock();
- if (self) {
- handleGetConsumerStats(result, stats, latchPtr, statsPtr,
index, callback);
- }
- });
+ auto indexPtr = std::make_shared<std::atomic<size_t>>(0);
+ auto weakSelf = weak_from_this();
+ consumers_.forEachValue([weakSelf, latchPtr, statsPtr, indexPtr,
callback](const ConsumerImplPtr& consumer) {
Review Comment:
The callback of `forEachValue` is immediately executed in the current method.
https://github.com/apache/pulsar-client-cpp/blob/0b893a1622aa7dd702d48afee33af321bb2c06dd/lib/SynchronizedHashMap.h#L95-L99
so I believe this patch does not fix the actual issue
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]