index: fix thread-sanitizer issue
Need a lock to access workers_;
This commit is contained in:
@ -298,11 +298,17 @@ Indexer::Private::scan_worker()
|
|||||||
// now there may still be messages in the work queue...
|
// now there may still be messages in the work queue...
|
||||||
// finish those; this is a bit ugly; perhaps we should
|
// finish those; this is a bit ugly; perhaps we should
|
||||||
// handle SIGTERM etc.
|
// handle SIGTERM etc.
|
||||||
if (!todos_.empty())
|
|
||||||
g_debug("process %zu remaining message(s) with %zu worker(s)", todos_.size(),
|
if (!todos_.empty()) {
|
||||||
workers_.size());
|
const auto workers_size = std::invoke([this] {
|
||||||
while (!todos_.empty())
|
std::lock_guard lock{w_lock_};
|
||||||
std::this_thread::sleep_for(100ms);
|
return workers_.size();
|
||||||
|
});
|
||||||
|
g_debug("process %zu remaining message(s) with %zu worker(s)",
|
||||||
|
todos_.size(), workers_size);
|
||||||
|
while (!todos_.empty())
|
||||||
|
std::this_thread::sleep_for(100ms);
|
||||||
|
}
|
||||||
|
|
||||||
store_.commit();
|
store_.commit();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user