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
5a50fa71
Commit
5a50fa71
authored
Apr 13, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
block signals when writing db to ensure db isn't corrupted
git-svn-id:
https://svn.musicpd.org/mpd/trunk@730
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
acf0e147
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
0 deletions
+14
-0
directory.c
src/directory.c
+7
-0
sig_handlers.c
src/sig_handlers.c
+4
-0
song.c
src/song.c
+2
-0
tag.c
src/tag.c
+1
-0
No files found.
src/directory.c
View file @
5a50fa71
...
...
@@ -553,6 +553,7 @@ int printDirectoryInfo(FILE * fp, char * name) {
return
0
;
}
/* DON'T BLOCK SIGNALS IN THIS FUNCTION, called by writeDirectoryDB() */
void
writeDirectoryInfo
(
FILE
*
fp
,
Directory
*
directory
)
{
ListNode
*
node
=
(
directory
->
subDirectories
)
->
firstNode
;
Directory
*
subDirectory
;
...
...
@@ -684,12 +685,18 @@ int writeDirectoryDB() {
while
(
!
(
fp
=
fopen
(
directorydb
,
"w"
))
&&
errno
==
EINTR
);
if
(
!
fp
)
return
-
1
;
/* block signals so we ensure the db doesn't get corrupted */
/* no functions that writeDirectoryInfoCalls should mess with
signals or signal blocking! */
blockSignals
();
myfprintf
(
fp
,
"%s
\n
"
,
DIRECTORY_INFO_BEGIN
);
myfprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_MPD_VERSION
,
VERSION
);
myfprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_FS_CHARSET
,
getFsCharset
());
myfprintf
(
fp
,
"%s
\n
"
,
DIRECTORY_INFO_END
);
writeDirectoryInfo
(
fp
,
mp3rootDirectory
);
unblockSignals
();
while
(
fclose
(
fp
)
&&
errno
==
EINTR
);
return
0
;
...
...
src/sig_handlers.c
View file @
5a50fa71
...
...
@@ -90,6 +90,8 @@ void blockSignals() {
sigaddset
(
&
sset
,
SIGCHLD
);
sigaddset
(
&
sset
,
SIGUSR1
);
sigaddset
(
&
sset
,
SIGHUP
);
sigaddset
(
&
sset
,
SIGINT
);
sigaddset
(
&
sset
,
SIGTERM
);
while
(
sigprocmask
(
SIG_BLOCK
,
&
sset
,
NULL
)
<
0
&&
errno
==
EINTR
);
}
...
...
@@ -100,5 +102,7 @@ void unblockSignals() {
sigaddset
(
&
sset
,
SIGCHLD
);
sigaddset
(
&
sset
,
SIGUSR1
);
sigaddset
(
&
sset
,
SIGHUP
);
sigaddset
(
&
sset
,
SIGINT
);
sigaddset
(
&
sset
,
SIGTERM
);
while
(
sigprocmask
(
SIG_UNBLOCK
,
&
sset
,
NULL
)
<
0
&&
errno
==
EINTR
);
}
src/song.c
View file @
5a50fa71
...
...
@@ -132,6 +132,7 @@ void freeSongList(SongList * list) {
freeList
(
list
);
}
/* DON'T BLOCK SIGNALS IN THIS FUNCTION, called by writeDirectoryDB() */
int
printSongInfo
(
FILE
*
fp
,
Song
*
song
)
{
myfprintf
(
fp
,
"%s%s
\n
"
,
SONG_FILE
,
song
->
utf8file
);
...
...
@@ -151,6 +152,7 @@ int printSongInfoFromList(FILE * fp, SongList * list) {
return
0
;
}
/* DON'T BLOCK SIGNALS IN THIS FUNCTION, called by writeDirectoryDB() */
void
writeSongInfoFromList
(
FILE
*
fp
,
SongList
*
list
)
{
ListNode
*
tempNode
=
list
->
firstNode
;
...
...
src/tag.c
View file @
5a50fa71
...
...
@@ -51,6 +51,7 @@
#include "mp4ff/mp4ff.h"
#endif
/* DON'T BLOCK SIGNALS IN THIS FUNCTION, called by writeDirectoryDB() */
void
printMpdTag
(
FILE
*
fp
,
MpdTag
*
tag
)
{
if
(
tag
->
artist
)
myfprintf
(
fp
,
"Artist: %s
\n
"
,
tag
->
artist
);
if
(
tag
->
album
)
myfprintf
(
fp
,
"Album: %s
\n
"
,
tag
->
album
);
...
...
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