From 0240e75426f483ff558422f99e29708e3f31fdb7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 5 Sep 2012 20:50:15 +0200 Subject: db_lock: add C++ helper class ScopeDatabaseLock --- src/db/SimpleDatabasePlugin.cxx | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/db/SimpleDatabasePlugin.cxx') diff --git a/src/db/SimpleDatabasePlugin.cxx b/src/db/SimpleDatabasePlugin.cxx index 54441f4cd..1e5ffe9bb 100644 --- a/src/db/SimpleDatabasePlugin.cxx +++ b/src/db/SimpleDatabasePlugin.cxx @@ -250,11 +250,8 @@ SimpleDatabase::LookupDirectory(const char *uri) const assert(root != NULL); assert(uri != NULL); - db_lock(); - struct directory *directory = - directory_lookup_directory(root, uri); - db_unlock(); - return directory; + ScopeDatabaseLock protect; + return directory_lookup_directory(root, uri); } bool @@ -281,12 +278,10 @@ SimpleDatabase::Visit(const DatabaseSelection &selection, !visit_directory(*directory, error_r)) return false; - db_lock(); - bool ret = directory->Walk(selection.recursive, selection.filter, - visit_directory, visit_song, visit_playlist, - error_r); - db_unlock(); - return ret; + ScopeDatabaseLock protect; + return directory->Walk(selection.recursive, selection.filter, + visit_directory, visit_song, visit_playlist, + error_r); } bool -- cgit v1.2.3