db/simple: use class ScopeDatabaseLock

This commit is contained in:
Max Kellermann
2015-12-15 23:27:05 +01:00
parent 7dd3b72a8c
commit e31f0b8b0c
8 changed files with 100 additions and 83 deletions

View File

@@ -80,9 +80,11 @@ UpdateService::CancelMount(const char *uri)
/* determine which (mounted) database will be updated and what
storage will be scanned */
db_lock();
const auto lr = db.GetRoot().LookupDirectory(uri);
db_unlock();
Directory::LookupResult lr;
{
const ScopeDatabaseLock protect;
lr = db.GetRoot().LookupDirectory(uri);
}
if (!lr.directory->IsMount())
return;
@@ -188,9 +190,12 @@ UpdateService::Enqueue(const char *path, bool discard)
SimpleDatabase *db2;
Storage *storage2;
db_lock();
const auto lr = db.GetRoot().LookupDirectory(path);
db_unlock();
Directory::LookupResult lr;
{
const ScopeDatabaseLock protect;
lr = db.GetRoot().LookupDirectory(path);
}
if (lr.directory->IsMount()) {
/* follow the mountpoint, update the mounted
database */