Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
c11345c4
Commit
c11345c4
authored
Dec 15, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/DatabaseLock: add class ScopeDatabaseUnlock
parent
e31f0b8b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
11 deletions
+22
-11
DatabaseLock.hxx
src/db/DatabaseLock.hxx
+14
-0
Directory.cxx
src/db/plugins/simple/Directory.cxx
+6
-8
Editor.cxx
src/db/update/Editor.cxx
+2
-3
No files found.
src/db/DatabaseLock.hxx
View file @
c11345c4
...
...
@@ -107,4 +107,18 @@ public:
}
};
/**
* Unlock the database while in the current scope.
*/
class
ScopeDatabaseUnlock
{
public
:
ScopeDatabaseUnlock
()
{
db_unlock
();
}
~
ScopeDatabaseUnlock
()
{
db_lock
();
}
};
#endif
src/db/plugins/simple/Directory.cxx
View file @
c11345c4
...
...
@@ -232,14 +232,12 @@ Directory::Walk(bool recursive, const SongFilter *filter,
/* TODO: eliminate this unlock/lock; it is necessary
because the child's SimpleDatabasePlugin::Visit()
call will lock it again */
db_unlock
();
bool
result
=
WalkMount
(
GetPath
(),
*
mounted_database
,
recursive
,
filter
,
visit_directory
,
visit_song
,
visit_playlist
,
error
);
db_lock
();
return
result
;
const
ScopeDatabaseUnlock
unlock
;
return
WalkMount
(
GetPath
(),
*
mounted_database
,
recursive
,
filter
,
visit_directory
,
visit_song
,
visit_playlist
,
error
);
}
if
(
visit_song
)
{
...
...
src/db/update/Editor.cxx
View file @
c11345c4
...
...
@@ -36,15 +36,14 @@ DatabaseEditor::DeleteSong(Directory &dir, Song *del)
/* first, prevent traversers in main task from getting this */
dir
.
RemoveSong
(
del
);
db_unlock
();
/* temporary unlock, because update_remove_song() blocks */
/* temporary unlock, because update_remove_song() blocks */
const
ScopeDatabaseUnlock
unlock
;
/* now take it out of the playlist (in the main_task) */
remove
.
Remove
(
del
);
/* finally, all possible references gone, free it */
del
->
Free
();
db_lock
();
}
void
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment