Slightly experimental change to speed up indexer exit after interrupt by closing up all queues.

This commit is contained in:
Jean-Francois Dockes
2021-11-24 19:46:56 +01:00
parent 5f2716e628
commit 02c9a6f3f7
5 changed files with 59 additions and 38 deletions
+27 -24
View File
@@ -236,20 +236,12 @@ bool FsIndexer::index(int flags)
}
}
#ifdef IDX_THREADS
if (m_haveInternQ)
m_iwqueue.waitIdle();
if (m_haveSplitQ)
m_dwqueue.waitIdle();
m_db->waitUpdIdle();
#endif // IDX_THREADS
shutdownQueues(walkok);
if (m_missing) {
string missing;
m_missing->getMissingDescription(missing);
if (!missing.empty()) {
LOGINFO("FsIndexer::index missing helper program(s):\n" <<
missing << "\n");
LOGINFO("FsIndexer::index missing helper program(s):\n" << missing << "\n");
}
m_config->storeMissingHelperDesc(missing);
}
@@ -257,6 +249,29 @@ bool FsIndexer::index(int flags)
return walkok;
}
void FsIndexer::shutdownQueues(bool ok)
{
#ifdef IDX_THREADS
if (!ok) {
// Error or more probably interrupt. Discard everything for fast shutdown
if (m_haveInternQ) {
m_iwqueue.closeShop();
}
if (m_haveSplitQ) {
m_dwqueue.closeShop();
}
m_db->closeQueue();
}
if (m_haveInternQ) {
m_iwqueue.waitIdle();
}
if (m_haveSplitQ) {
m_dwqueue.waitIdle();
}
m_db->waitUpdIdle();
#endif // IDX_THREADS
}
static bool matchesSkipped(
const vector<string>& tdl, FsTreeWalker& walker, const string& path)
{
@@ -406,13 +421,7 @@ bool FsIndexer::indexFiles(list<string>& files, int flags)
ret = true;
out:
#ifdef IDX_THREADS
if (m_haveInternQ)
m_iwqueue.waitIdle();
if (m_haveSplitQ)
m_dwqueue.waitIdle();
m_db->waitUpdIdle();
#endif // IDX_THREADS
shutdownQueues(ret);
// Purge possible orphan documents
if (ret == true) {
@@ -461,13 +470,7 @@ bool FsIndexer::purgeFiles(list<string>& files)
ret = true;
out:
#ifdef IDX_THREADS
if (m_haveInternQ)
m_iwqueue.waitIdle();
if (m_haveSplitQ)
m_dwqueue.waitIdle();
m_db->waitUpdIdle();
#endif // IDX_THREADS
shutdownQueues(ret);
LOGDEB("FsIndexer::purgeFiles: done\n");
return ret;
}
+1
View File
@@ -159,6 +159,7 @@ private:
processonefile(RclConfig *config, const string &fn,
const struct PathStat *,
const map<string,string>& localfields);
void shutdownQueues(bool);
};
#endif /* _fsindexer_h_included_ */