mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-12 22:10:54 -04:00
Fix data race in filesystem_writer
This commit is contained in:
parent
6177090eca
commit
961a0292c3
@ -404,15 +404,12 @@ void filesystem_writer_<LoggerPolicy>::write_section(
|
|||||||
while (mem_used() > options_.max_queue_size) {
|
while (mem_used() > options_.max_queue_size) {
|
||||||
cond_.wait(lock);
|
cond_.wait(lock);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
auto fsb =
|
auto fsb =
|
||||||
std::make_unique<fsblock>(type, bc, std::move(data), section_number_++);
|
std::make_unique<fsblock>(type, bc, std::move(data), section_number_++);
|
||||||
|
|
||||||
fsb->compress(wg_);
|
fsb->compress(wg_);
|
||||||
|
|
||||||
{
|
|
||||||
std::lock_guard lock(mx_);
|
|
||||||
queue_.push_back(std::move(fsb));
|
queue_.push_back(std::move(fsb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,13 +420,14 @@ template <typename LoggerPolicy>
|
|||||||
void filesystem_writer_<LoggerPolicy>::write_compressed_section(
|
void filesystem_writer_<LoggerPolicy>::write_compressed_section(
|
||||||
section_type type, compression_type compression,
|
section_type type, compression_type compression,
|
||||||
std::span<uint8_t const> data) {
|
std::span<uint8_t const> data) {
|
||||||
auto fsb =
|
|
||||||
std::make_unique<fsblock>(type, compression, data, section_number_++);
|
|
||||||
|
|
||||||
fsb->compress(wg_);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard lock(mx_);
|
std::lock_guard lock(mx_);
|
||||||
|
|
||||||
|
auto fsb =
|
||||||
|
std::make_unique<fsblock>(type, compression, data, section_number_++);
|
||||||
|
|
||||||
|
fsb->compress(wg_);
|
||||||
|
|
||||||
queue_.push_back(std::move(fsb));
|
queue_.push_back(std::move(fsb));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user