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
5ee3a9a9
Commit
5ee3a9a9
authored
Feb 13, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist_vector: require database lock for all functions
parent
dd26fa67
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
3 deletions
+27
-3
playlist_vector.c
src/playlist_vector.c
+8
-0
playlist_vector.h
src/playlist_vector.h
+11
-0
update_db.c
src/update_db.c
+2
-2
update_walk.c
src/update_walk.c
+6
-1
No files found.
src/playlist_vector.c
View file @
5ee3a9a9
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include "config.h"
#include "config.h"
#include "playlist_vector.h"
#include "playlist_vector.h"
#include "db_lock.h"
#include <assert.h>
#include <assert.h>
#include <string.h>
#include <string.h>
...
@@ -58,6 +59,7 @@ playlist_vector_deinit(struct list_head *pv)
...
@@ -58,6 +59,7 @@ playlist_vector_deinit(struct list_head *pv)
struct
playlist_metadata
*
struct
playlist_metadata
*
playlist_vector_find
(
struct
list_head
*
pv
,
const
char
*
name
)
playlist_vector_find
(
struct
list_head
*
pv
,
const
char
*
name
)
{
{
assert
(
holding_db_lock
());
assert
(
pv
!=
NULL
);
assert
(
pv
!=
NULL
);
assert
(
name
!=
NULL
);
assert
(
name
!=
NULL
);
...
@@ -73,6 +75,8 @@ void
...
@@ -73,6 +75,8 @@ void
playlist_vector_add
(
struct
list_head
*
pv
,
playlist_vector_add
(
struct
list_head
*
pv
,
const
char
*
name
,
time_t
mtime
)
const
char
*
name
,
time_t
mtime
)
{
{
assert
(
holding_db_lock
());
struct
playlist_metadata
*
pm
=
playlist_metadata_new
(
name
,
mtime
);
struct
playlist_metadata
*
pm
=
playlist_metadata_new
(
name
,
mtime
);
list_add_tail
(
&
pm
->
siblings
,
pv
);
list_add_tail
(
&
pm
->
siblings
,
pv
);
}
}
...
@@ -81,6 +85,8 @@ bool
...
@@ -81,6 +85,8 @@ bool
playlist_vector_update_or_add
(
struct
list_head
*
pv
,
playlist_vector_update_or_add
(
struct
list_head
*
pv
,
const
char
*
name
,
time_t
mtime
)
const
char
*
name
,
time_t
mtime
)
{
{
assert
(
holding_db_lock
());
struct
playlist_metadata
*
pm
=
playlist_vector_find
(
pv
,
name
);
struct
playlist_metadata
*
pm
=
playlist_vector_find
(
pv
,
name
);
if
(
pm
!=
NULL
)
{
if
(
pm
!=
NULL
)
{
if
(
mtime
==
pm
->
mtime
)
if
(
mtime
==
pm
->
mtime
)
...
@@ -96,6 +102,8 @@ playlist_vector_update_or_add(struct list_head *pv,
...
@@ -96,6 +102,8 @@ playlist_vector_update_or_add(struct list_head *pv,
bool
bool
playlist_vector_remove
(
struct
list_head
*
pv
,
const
char
*
name
)
playlist_vector_remove
(
struct
list_head
*
pv
,
const
char
*
name
)
{
{
assert
(
holding_db_lock
());
struct
playlist_metadata
*
pm
=
playlist_vector_find
(
pv
,
name
);
struct
playlist_metadata
*
pm
=
playlist_vector_find
(
pv
,
name
);
if
(
pm
==
NULL
)
if
(
pm
==
NULL
)
return
false
;
return
false
;
...
...
src/playlist_vector.h
View file @
5ee3a9a9
...
@@ -49,20 +49,31 @@ struct playlist_metadata {
...
@@ -49,20 +49,31 @@ struct playlist_metadata {
void
void
playlist_vector_deinit
(
struct
list_head
*
pv
);
playlist_vector_deinit
(
struct
list_head
*
pv
);
/**
* Caller must lock the #db_mutex.
*/
struct
playlist_metadata
*
struct
playlist_metadata
*
playlist_vector_find
(
struct
list_head
*
pv
,
const
char
*
name
);
playlist_vector_find
(
struct
list_head
*
pv
,
const
char
*
name
);
/**
* Caller must lock the #db_mutex.
*/
void
void
playlist_vector_add
(
struct
list_head
*
pv
,
playlist_vector_add
(
struct
list_head
*
pv
,
const
char
*
name
,
time_t
mtime
);
const
char
*
name
,
time_t
mtime
);
/**
/**
* Caller must lock the #db_mutex.
*
* @return true if the vector or one of its items was modified
* @return true if the vector or one of its items was modified
*/
*/
bool
bool
playlist_vector_update_or_add
(
struct
list_head
*
pv
,
playlist_vector_update_or_add
(
struct
list_head
*
pv
,
const
char
*
name
,
time_t
mtime
);
const
char
*
name
,
time_t
mtime
);
/**
* Caller must lock the #db_mutex.
*/
bool
bool
playlist_vector_remove
(
struct
list_head
*
pv
,
const
char
*
name
);
playlist_vector_remove
(
struct
list_head
*
pv
,
const
char
*
name
);
...
...
src/update_db.c
View file @
5ee3a9a9
...
@@ -96,9 +96,9 @@ delete_name_in(struct directory *parent, const char *name)
...
@@ -96,9 +96,9 @@ delete_name_in(struct directory *parent, const char *name)
modified
=
true
;
modified
=
true
;
}
}
db_unlock
();
playlist_vector_remove
(
&
parent
->
playlists
,
name
);
playlist_vector_remove
(
&
parent
->
playlists
,
name
);
db_unlock
();
return
modified
;
return
modified
;
}
}
src/update_walk.c
View file @
5ee3a9a9
...
@@ -162,8 +162,11 @@ removeDeletedFromDirectory(struct directory *directory)
...
@@ -162,8 +162,11 @@ removeDeletedFromDirectory(struct directory *directory)
struct
playlist_metadata
*
pm
,
*
np
;
struct
playlist_metadata
*
pm
,
*
np
;
directory_for_each_playlist_safe
(
pm
,
np
,
directory
)
{
directory_for_each_playlist_safe
(
pm
,
np
,
directory
)
{
if
(
!
directory_child_is_regular
(
directory
,
pm
->
name
))
if
(
!
directory_child_is_regular
(
directory
,
pm
->
name
))
{
db_lock
();
playlist_vector_remove
(
&
directory
->
playlists
,
pm
->
name
);
playlist_vector_remove
(
&
directory
->
playlists
,
pm
->
name
);
db_unlock
();
}
}
}
}
}
...
@@ -467,9 +470,11 @@ update_regular_file(struct directory *directory,
...
@@ -467,9 +470,11 @@ update_regular_file(struct directory *directory,
#endif
#endif
}
else
if
(
playlist_suffix_supported
(
suffix
))
{
}
else
if
(
playlist_suffix_supported
(
suffix
))
{
db_lock
();
if
(
playlist_vector_update_or_add
(
&
directory
->
playlists
,
name
,
if
(
playlist_vector_update_or_add
(
&
directory
->
playlists
,
name
,
st
->
st_mtime
))
st
->
st_mtime
))
modified
=
true
;
modified
=
true
;
db_unlock
();
}
}
}
}
...
...
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