Fixed bug with message leak in BufferedProducer::flush(timeout)

This commit is contained in:
accelerated
2018-12-14 16:08:57 -05:00
parent ab002fe119
commit 4a24971d3f

View File

@@ -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();