From db1a5c8dd2e83dd601407e5c31efb6ea1a841777 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 16 Apr 2022 16:49:25 +0300 Subject: [PATCH] indexer: don't wait when indexing does not progress Should help for #2233. --- lib/index/mu-indexer.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/index/mu-indexer.cc b/lib/index/mu-indexer.cc index 9a43316e..7e759251 100644 --- a/lib/index/mu-indexer.cc +++ b/lib/index/mu-indexer.cc @@ -276,12 +276,18 @@ Indexer::Private::start(const Indexer::Config& conf) fq_.size()); } - // now there may still be messages in the work queue... - // finish those; this is a bit ugly; perhaps we should - // handle SIGTERM etc. - while (!fq_.empty()) - std::this_thread::sleep_for(100ms); + // finish those; it's possible that the thread has already + // stopped, so stop when there's no progress. A bit ugly, fixed + // in >= 1.7 + { + while (!fq_.empty()) { + const auto n = fq_.size(); + std::this_thread::sleep_for(250ms); + if (fq_.size() >= n) + break; // no progress. + } + } if (conf_.cleanup) { g_debug ("starting cleanup");