From 58b1fc4914de8ad5afc774fbef54d848fc379013 Mon Sep 17 00:00:00 2001 From: kannibalox Date: Mon, 2 Dec 2024 09:27:12 -0500 Subject: [PATCH] Ensure empty() is properly guarded --- src/thread_base.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/thread_base.cc b/src/thread_base.cc index 6564133a..c74fb3a8 100644 --- a/src/thread_base.cc +++ b/src/thread_base.cc @@ -20,10 +20,13 @@ public: using value_type = ThreadBase::thread_base_func; using base_type = std::vector; - using base_type::empty; - thread_queue_hack() { reserve(max_size); }; + bool empty() { + std::lock_guard lguard(m_lock); + return base_type::empty(); + } + void push_back(value_type v) { if (size() >= max_size) throw torrent::internal_error("Overflowed thread_queue max size of " + std::to_string(max_size) + ".");