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
b5bdc71d
Commit
b5bdc71d
authored
Apr 13, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
have update process ignore signals when writing db
git-svn-id:
https://svn.musicpd.org/mpd/trunk@735
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
860f8bda
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
0 deletions
+21
-0
directory.c
src/directory.c
+5
-0
sig_handlers.c
src/sig_handlers.c
+14
-0
sig_handlers.h
src/sig_handlers.h
+2
-0
No files found.
src/directory.c
View file @
b5bdc71d
...
@@ -150,6 +150,8 @@ int updateInit(FILE * fp, List * pathList) {
...
@@ -150,6 +150,8 @@ int updateInit(FILE * fp, List * pathList) {
directory_updatePid
=
fork
();
directory_updatePid
=
fork
();
if
(
directory_updatePid
==
0
)
{
if
(
directory_updatePid
==
0
)
{
/* child */
/* child */
struct
sigaction
sa
;
clearPlayerPid
();
clearPlayerPid
();
unblockSignals
();
unblockSignals
();
...
@@ -186,6 +188,8 @@ int updateInit(FILE * fp, List * pathList) {
...
@@ -186,6 +188,8 @@ int updateInit(FILE * fp, List * pathList) {
}
}
}
}
else
if
(
updateDirectory
(
mp3rootDirectory
)
<
0
)
exit
(
EXIT_FAILURE
);
else
if
(
updateDirectory
(
mp3rootDirectory
)
<
0
)
exit
(
EXIT_FAILURE
);
/* ignore signals since we don't want them to corrupt the db*/
ignoreSignals
();
if
(
writeDirectoryDB
()
<
0
)
{
if
(
writeDirectoryDB
()
<
0
)
{
ERROR
(
"problems writing music db file,
\"
%s
\"\n
"
,
ERROR
(
"problems writing music db file,
\"
%s
\"\n
"
,
directorydb
);
directorydb
);
...
@@ -684,6 +688,7 @@ int writeDirectoryDB() {
...
@@ -684,6 +688,7 @@ int writeDirectoryDB() {
while
(
!
(
fp
=
fopen
(
directorydb
,
"w"
))
&&
errno
==
EINTR
);
while
(
!
(
fp
=
fopen
(
directorydb
,
"w"
))
&&
errno
==
EINTR
);
if
(
!
fp
)
return
-
1
;
if
(
!
fp
)
return
-
1
;
/* block signals when writing the db so we don't get a corrupted db*/
myfprintf
(
fp
,
"%s
\n
"
,
DIRECTORY_INFO_BEGIN
);
myfprintf
(
fp
,
"%s
\n
"
,
DIRECTORY_INFO_BEGIN
);
myfprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_MPD_VERSION
,
VERSION
);
myfprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_MPD_VERSION
,
VERSION
);
myfprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_FS_CHARSET
,
getFsCharset
());
myfprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_FS_CHARSET
,
getFsCharset
());
...
...
src/sig_handlers.c
View file @
b5bdc71d
...
@@ -83,6 +83,20 @@ void finishSigHandlers() {
...
@@ -83,6 +83,20 @@ void finishSigHandlers() {
signal_unhandle
(
SIGHUP
);
signal_unhandle
(
SIGHUP
);
}
}
void
ignoreSignals
()
{
struct
sigaction
sa
;
sa
.
sa_flags
=
0
;
sigemptyset
(
&
sa
.
sa_mask
);
sa
.
sa_handler
=
SIG_IGN
;
while
(
sigaction
(
SIGPIPE
,
&
sa
,
NULL
)
<
0
&&
errno
==
EINTR
);
while
(
sigaction
(
SIGCHLD
,
&
sa
,
NULL
)
<
0
&&
errno
==
EINTR
);
while
(
sigaction
(
SIGUSR1
,
&
sa
,
NULL
)
<
0
&&
errno
==
EINTR
);
while
(
sigaction
(
SIGINT
,
&
sa
,
NULL
)
<
0
&&
errno
==
EINTR
);
while
(
sigaction
(
SIGTERM
,
&
sa
,
NULL
)
<
0
&&
errno
==
EINTR
);
while
(
sigaction
(
SIGHUP
,
&
sa
,
NULL
)
<
0
&&
errno
==
EINTR
);
}
void
blockSignals
()
{
void
blockSignals
()
{
sigset_t
sset
;
sigset_t
sset
;
...
...
src/sig_handlers.h
View file @
b5bdc71d
...
@@ -27,6 +27,8 @@ void initSigHandlers();
...
@@ -27,6 +27,8 @@ void initSigHandlers();
void
finishSigHandlers
();
void
finishSigHandlers
();
void
ignoreSignals
();
void
blockSignals
();
void
blockSignals
();
void
unblockSignals
();
void
unblockSignals
();
...
...
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