Clear index requests upon "exit"

to make indexers stop in time. This is especially relevant when there
are many initial index requests.
This commit is contained in:
Fangrui Song 2025-01-28 10:33:50 -08:00
parent 48f1a006b7
commit 962c0e72b4

View File

@ -684,6 +684,14 @@ void mainLoop() {
path2backlog[ex.path].push_back(&backlog.back());
}
// If the "exit" notification has been received, clear all index requests
// to make indexers stop in time.
if (g_quit.load(std::memory_order_relaxed)) {
index_request->apply([&](std::deque<IndexRequest> &q) {
q.clear();
});
}
bool indexed = false;
for (int i = 20; i--;) {
std::optional<IndexUpdate> update = on_indexed->tryPopFront();