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
26970579
Commit
26970579
authored
Jan 31, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/update/Editor: add locking method variants
parent
04b4f534
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
27 deletions
+36
-27
Container.cxx
src/db/update/Container.cxx
+1
-3
Editor.cxx
src/db/update/Editor.cxx
+16
-0
Editor.hxx
src/db/update/Editor.hxx
+10
-0
UpdateSong.cxx
src/db/update/UpdateSong.cxx
+5
-13
Walk.cxx
src/db/update/Walk.cxx
+4
-11
No files found.
src/db/update/Container.cxx
View file @
26970579
...
...
@@ -118,9 +118,7 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
}
if
(
tnum
==
1
)
{
db_lock
();
editor
.
DeleteDirectory
(
contdir
);
db_unlock
();
editor
.
LockDeleteDirectory
(
contdir
);
return
false
;
}
else
return
true
;
...
...
src/db/update/Editor.cxx
View file @
26970579
...
...
@@ -47,6 +47,14 @@ DatabaseEditor::DeleteSong(Directory &dir, Song *del)
db_lock
();
}
void
DatabaseEditor
::
LockDeleteSong
(
Directory
&
parent
,
Song
*
song
)
{
db_lock
();
DeleteSong
(
parent
,
song
);
db_unlock
();
}
/**
* Recursively remove all sub directories and songs from a directory,
* leaving an empty directory.
...
...
@@ -77,6 +85,14 @@ DatabaseEditor::DeleteDirectory(Directory *directory)
directory
->
Delete
();
}
void
DatabaseEditor
::
LockDeleteDirectory
(
Directory
*
directory
)
{
db_lock
();
DeleteDirectory
(
directory
);
db_unlock
();
}
bool
DatabaseEditor
::
DeleteNameIn
(
Directory
&
parent
,
const
char
*
name
)
{
...
...
src/db/update/Editor.hxx
View file @
26970579
...
...
@@ -40,6 +40,11 @@ public:
void
DeleteSong
(
Directory
&
parent
,
Song
*
song
);
/**
* DeleteSong() with automatic locking.
*/
void
LockDeleteSong
(
Directory
&
parent
,
Song
*
song
);
/**
* Recursively free a directory and all its contents.
*
* Caller must lock the #db_mutex.
...
...
@@ -47,6 +52,11 @@ public:
void
DeleteDirectory
(
Directory
*
directory
);
/**
* DeleteDirectory() with automatic locking.
*/
void
LockDeleteDirectory
(
Directory
*
directory
);
/**
* Caller must NOT lock the #db_mutex.
*
* @return true if the database was modified
...
...
src/db/update/UpdateSong.cxx
View file @
26970579
...
...
@@ -42,11 +42,8 @@ UpdateWalk::UpdateSongFile2(Directory &directory,
FormatError
(
update_domain
,
"no read permissions on %s/%s"
,
directory
.
GetPath
(),
name
);
if
(
song
!=
nullptr
)
{
db_lock
();
editor
.
DeleteSong
(
directory
,
song
);
db_unlock
();
}
if
(
song
!=
nullptr
)
editor
.
LockDeleteSong
(
directory
,
song
);
return
;
}
...
...
@@ -54,11 +51,8 @@ UpdateWalk::UpdateSongFile2(Directory &directory,
if
(
!
(
song
!=
nullptr
&&
st
->
st_mtime
==
song
->
mtime
&&
!
walk_discard
)
&&
UpdateContainerFile
(
directory
,
name
,
suffix
,
st
))
{
if
(
song
!=
nullptr
)
{
db_lock
();
editor
.
DeleteSong
(
directory
,
song
);
db_unlock
();
}
if
(
song
!=
nullptr
)
editor
.
LockDeleteSong
(
directory
,
song
);
return
;
}
...
...
@@ -88,9 +82,7 @@ UpdateWalk::UpdateSongFile2(Directory &directory,
FormatDebug
(
update_domain
,
"deleting unrecognized file %s/%s"
,
directory
.
GetPath
(),
name
);
db_lock
();
editor
.
DeleteSong
(
directory
,
song
);
db_unlock
();
editor
.
LockDeleteSong
(
directory
,
song
);
}
modified
=
true
;
...
...
src/db/update/Walk.cxx
View file @
26970579
...
...
@@ -107,9 +107,7 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory)
if
(
directory_exists
(
*
child
))
continue
;
db_lock
();
editor
.
DeleteDirectory
(
child
);
db_unlock
();
editor
.
LockDeleteDirectory
(
child
);
modified
=
true
;
}
...
...
@@ -118,9 +116,7 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory)
directory_for_each_song_safe
(
song
,
ns
,
directory
)
{
const
auto
path
=
map_song_fs
(
*
song
);
if
(
path
.
IsNull
()
||
!
FileExists
(
path
))
{
db_lock
();
editor
.
DeleteSong
(
directory
,
song
);
db_unlock
();
editor
.
LockDeleteSong
(
directory
,
song
);
modified
=
true
;
}
...
...
@@ -223,11 +219,8 @@ UpdateWalk::UpdateDirectoryChild(Directory &directory,
assert
(
&
directory
==
subdir
->
parent
);
if
(
!
UpdateDirectory
(
*
subdir
,
st
))
{
db_lock
();
editor
.
DeleteDirectory
(
subdir
);
db_unlock
();
}
if
(
!
UpdateDirectory
(
*
subdir
,
st
))
editor
.
LockDeleteDirectory
(
subdir
);
}
else
{
FormatDebug
(
update_domain
,
"%s is not a directory, archive or music"
,
name
);
...
...
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