mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-11-01 11:07:56 +00:00
Fix tracker promise from throwing when set multiple times
This commit is contained in:
@@ -771,7 +771,16 @@ void BufferedProducer<BufferType, Allocator>::clear() {
|
||||
|
||||
template <typename BufferType, typename Allocator>
|
||||
size_t BufferedProducer<BufferType, Allocator>::get_buffer_size() const {
|
||||
return messages_.size() + retry_messages_.size();
|
||||
int size = 0;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
size += messages_.size();
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(retry_mutex_);
|
||||
size += retry_messages_.size();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
template <typename BufferType, typename Allocator>
|
||||
@@ -1025,7 +1034,12 @@ void BufferedProducer<BufferType, Allocator>::on_delivery_report(const Message&
|
||||
}
|
||||
// Signal producers
|
||||
if (tracker) {
|
||||
tracker->should_retry_.set_value(should_retry);
|
||||
try {
|
||||
tracker->should_retry_.set_value(should_retry);
|
||||
}
|
||||
catch (const std::future_error& ex) {
|
||||
//This is an async retry and future is not being read
|
||||
}
|
||||
}
|
||||
// Decrement the expected acks and check to prevent underflow
|
||||
if (pending_acks_ > 0) {
|
||||
|
||||
Reference in New Issue
Block a user