aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/update/Service.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-27 16:36:11 +0100
committerMax Kellermann <max@duempel.org>2014-02-27 16:58:35 +0100
commit681e012fb542ee1bb2ea5312dc673987a7a8ee29 (patch)
tree2887e01d906c89f99516d67c555a2318473cc169 /src/db/update/Service.cxx
parent3be36643a1bded02171d8ddaac7d7aecfdc1915a (diff)
downloadmpd-681e012fb542ee1bb2ea5312dc673987a7a8ee29.tar.gz
mpd-681e012fb542ee1bb2ea5312dc673987a7a8ee29.tar.xz
mpd-681e012fb542ee1bb2ea5312dc673987a7a8ee29.zip
db/update: cancel the update on shutdown
Diffstat (limited to '')
-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);