db/update: cancel the update on shutdown

This commit is contained in:
Max Kellermann
2014-02-27 16:36:11 +01:00
parent 3be36643a1
commit 681e012fb5
7 changed files with 59 additions and 1 deletions

View File

@@ -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);