mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-10-31 18:47:48 +00:00
Fixed bug with message leak in BufferedProducer::flush(timeout)
This commit is contained in:
@@ -581,6 +581,12 @@ bool BufferedProducer<BufferType, Allocator>::flush(std::chrono::milliseconds ti
|
||||
remaining = timeout - std::chrono::duration_cast<std::chrono::milliseconds>
|
||||
(std::chrono::high_resolution_clock::now() - start_time);
|
||||
} while (!flush_queue.empty() && (remaining.count() > 0));
|
||||
|
||||
// Re-enqueue remaining messages in original order
|
||||
if (!flush_queue.empty()) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
messages_.insert(messages_.begin(), std::make_move_iterator(flush_queue.rbegin()), std::make_move_iterator(flush_queue.rend()))
|
||||
}
|
||||
}
|
||||
else {
|
||||
async_flush();
|
||||
|
||||
Reference in New Issue
Block a user