From 681e012fb542ee1bb2ea5312dc673987a7a8ee29 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 27 Feb 2014 16:36:11 +0100 Subject: db/update: cancel the update on shutdown --- src/db/update/Service.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/db/update/Service.cxx') 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); -- cgit v1.2.3