fix: race for statebuf_ in simple progress mode

This commit is contained in:
Marcus Holland-Moritz 2023-12-22 22:54:43 +01:00
parent 9adf183117
commit 1590abbac3

View File

@ -307,14 +307,13 @@ void console_writer::update(progress& p, bool last) {
std::string tmp = std::string tmp =
fmt::format(" ==> {0:.0f}% done, {1} blocks/{2} written", 100 * frac_, fmt::format(" ==> {0:.0f}% done, {1} blocks/{2} written", 100 * frac_,
p.blocks_written.load(), size_with_unit(p.compressed_size)); p.blocks_written.load(), size_with_unit(p.compressed_size));
std::lock_guard lock(log_mutex());
if (tmp != statebuf_) { if (tmp != statebuf_) {
auto t = get_current_time_string(); auto t = get_current_time_string();
statebuf_ = tmp; statebuf_ = tmp;
std::lock_guard lock(log_mutex());
log_stream() << "- " << t << statebuf_ << "\n"; log_stream() << "- " << t << statebuf_ << "\n";
} }
if (last) { if (last) {
std::lock_guard lock(log_mutex());
log_stream() << oss.str(); log_stream() << oss.str();
} }
} else { } else {