aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/update/Service.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/update/Service.cxx')
-rw-r--r--src/db/update/Service.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/db/update/Service.cxx b/src/db/update/Service.cxx
index 0018e2cc0..112d97760 100644
--- a/src/db/update/Service.cxx
+++ b/src/db/update/Service.cxx
@@ -47,6 +47,23 @@ UpdateService::UpdateService(EventLoop &_loop, SimpleDatabase &_db,
{
}
+UpdateService::~UpdateService()
+{
+ CancelAllAsync();
+
+ if (update_thread.IsDefined())
+ update_thread.Join();
+}
+
+void
+UpdateService::CancelAllAsync()
+{
+ assert(GetEventLoop().IsInsideOrNull());
+
+ queue.Clear();
+ walk.Cancel();
+}
+
inline void
UpdateService::Task()
{
@@ -94,6 +111,8 @@ UpdateService::StartThread(UpdateQueueItem &&i)
next = std::move(i);
+ walk.Prepare();
+
Error error;
if (!update_thread.Start(Task, this, error))
FatalError(error);