mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-11-02 19:47:55 +00:00
Merge pull request #235 from accelerated/promise_bug
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>
|
template <typename BufferType, typename Allocator>
|
||||||
size_t BufferedProducer<BufferType, Allocator>::get_buffer_size() const {
|
size_t BufferedProducer<BufferType, Allocator>::get_buffer_size() const {
|
||||||
return messages_.size() + retry_messages_.size();
|
size_t 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>
|
template <typename BufferType, typename Allocator>
|
||||||
@@ -1025,8 +1034,13 @@ void BufferedProducer<BufferType, Allocator>::on_delivery_report(const Message&
|
|||||||
}
|
}
|
||||||
// Signal producers
|
// Signal producers
|
||||||
if (tracker) {
|
if (tracker) {
|
||||||
|
try {
|
||||||
tracker->should_retry_.set_value(should_retry);
|
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
|
// Decrement the expected acks and check to prevent underflow
|
||||||
if (pending_acks_ > 0) {
|
if (pending_acks_ > 0) {
|
||||||
--pending_acks_;
|
--pending_acks_;
|
||||||
|
|||||||
Reference in New Issue
Block a user