From cee06b28f6cbcc4604e2ce07d6e90aeaa73c46be Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Tue, 22 Aug 2023 21:25:20 +0200 Subject: [PATCH] Delay compression progress until we actually start compressing --- src/dwarfs/filesystem_writer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dwarfs/filesystem_writer.cpp b/src/dwarfs/filesystem_writer.cpp index 731fddd6..1315b57f 100644 --- a/src/dwarfs/filesystem_writer.cpp +++ b/src/dwarfs/filesystem_writer.cpp @@ -358,7 +358,6 @@ filesystem_writer_::filesystem_writer_( , metadata_bc_(metadata_bc) , options_(options) , LOG_PROXY_INIT(lgr) - , pctx_{prog.create_context()} , flush_(false) , writer_thread_(&filesystem_writer_::writer_thread, this) { if (header_) { @@ -486,6 +485,10 @@ uint32_t filesystem_writer_::write_section( { std::unique_lock lock(mx_); + if (!pctx_) { + pctx_ = prog_.create_context(); + } + while (mem_used() > options_.max_queue_size) { cond_.wait(lock); }