From 159cf360c6795fe8afb8be9437bb6e12be6f70fd Mon Sep 17 00:00:00 2001 From: Alex Petty Date: Tue, 7 Jul 2026 15:11:04 -0400 Subject: [PATCH] Handle output file failures by logging an error and not trying to write to a bad output stream in a loop. --- src/reporter.hpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/reporter.hpp b/src/reporter.hpp index 07ae2eb..ce9194d 100755 --- a/src/reporter.hpp +++ b/src/reporter.hpp @@ -74,7 +74,11 @@ class Reporter { os.push(boost::iostreams::zstd_compressor()); os.push(sink); - while (!done || nstrings > 0) { + if (!os) { + fmt::print(std::cerr, "Error: Could not open {} for writing.\n", out_path); + } + + while ((!done || nstrings > 0) && os) { data_cond.wait_for(lk, std::chrono::seconds(1), [this] { return !string_queue.empty() || done; }); if (!string_queue.empty()) { s = std::move(string_queue.front()); @@ -91,6 +95,10 @@ class Reporter { lk.lock(); } } + + if (!os) { + fmt::print(std::cerr, "Error: Failure writing to {}.\n", out_path); + } } void print_debug() { @@ -163,7 +171,7 @@ class Reporter { std::unique_lock lk(deb); debug_queue.push(s); lk.unlock(); - debug_cond.notify_all(); + debug_cond.notify_one(); return; } else { std::unique_lock lk(mut); @@ -171,7 +179,7 @@ class Reporter { nstrings++; nsubmitted++; lk.unlock(); - data_cond.notify_all(); + data_cond.notify_one(); } }