From 962c0e72b41ac7574b901e52fdd29241a41cea0d Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 28 Jan 2025 10:33:50 -0800 Subject: [PATCH] Clear index requests upon "exit" to make indexers stop in time. This is especially relevant when there are many initial index requests. --- src/pipeline.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pipeline.cc b/src/pipeline.cc index 22debd17..0a8d85ab 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -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 &q) { + q.clear(); + }); + } + bool indexed = false; for (int i = 20; i--;) { std::optional update = on_indexed->tryPopFront();