aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2025-04-25 11:06:22 +0200
committerGitHub Enterprise <[email protected]>2025-04-25 11:06:22 +0200
commita1c40f05af26f374a5d1c5a7b5993b09d3c2fda8 (patch)
tree9b44801c0992d87fcde2e5d68dfa3fb0a2b4b4ae /src
parent5.6.6 (diff)
downloadzen-a1c40f05af26f374a5d1c5a7b5993b09d3c2fda8.tar.xz
zen-a1c40f05af26f374a5d1c5a7b5993b09d3c2fda8.zip
fix race in rpcrecorder (#375)
Diffstat (limited to 'src')
-rw-r--r--src/zenutil/cache/rpcrecording.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/zenutil/cache/rpcrecording.cpp b/src/zenutil/cache/rpcrecording.cpp
index 380c182b2..46e80f6b7 100644
--- a/src/zenutil/cache/rpcrecording.cpp
+++ b/src/zenutil/cache/rpcrecording.cpp
@@ -366,6 +366,7 @@ private:
};
std::unique_ptr<std::thread> m_WriterThread;
+ std::atomic_bool m_IsWriterReady{false};
std::atomic_bool m_IsActive{false};
std::atomic_int64_t m_PendingRequests{0};
RwLock m_RequestQueueLock;
@@ -658,6 +659,8 @@ RecordedRequestsWriter::BeginWrite(const std::filesystem::path& BasePath)
m_IsActive = true;
m_WriterThread.reset(new std::thread(&RecordedRequestsWriter::WriterThreadMain, this));
+
+ m_IsWriterReady.wait(false);
}
void
@@ -707,6 +710,9 @@ RecordedRequestsWriter::WriterThreadMain()
SetCurrentThreadName("rpc_writer");
EnsureCurrentSegment();
+ m_IsWriterReady.store(true);
+ m_IsWriterReady.notify_all();
+
while (m_IsActive)
{
m_PendingRequests.wait(0);