removing debug messages from signal handlers
As unfortunate as it is to remove such useful debugging messages, it's necessary to fix a potential deadlock with signal handling. A bunch of functions the debug functions call aren't safe to call from a signal handler. There are some alternate solutions, but they're neither pretty nor simple. So just remove them entirely for now. git-svn-id: https://svn.musicpd.org/mpd/trunk@6828 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
752bf24b74
commit
1b045d0672
@ -44,23 +44,25 @@ void decodeSigHandler(int sig, siginfo_t * si, void *v)
|
|||||||
if (sig == SIGCHLD) {
|
if (sig == SIGCHLD) {
|
||||||
int status;
|
int status;
|
||||||
if (decode_pid == wait3(&status, WNOHANG, NULL)) {
|
if (decode_pid == wait3(&status, WNOHANG, NULL)) {
|
||||||
|
/*
|
||||||
if (WIFSIGNALED(status)) {
|
if (WIFSIGNALED(status)) {
|
||||||
if (WTERMSIG(status) != SIGTERM) {
|
if (WTERMSIG(status) != SIGTERM) {
|
||||||
ERROR("decode process died from "
|
ERROR("decode process died from "
|
||||||
"signal: %i\n", WTERMSIG(status));
|
"signal: %i\n", WTERMSIG(status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
decode_pid = 0;
|
decode_pid = 0;
|
||||||
getPlayerData()->playerControl.decode_pid = 0;
|
getPlayerData()->playerControl.decode_pid = 0;
|
||||||
}
|
}
|
||||||
} else if (sig == SIGTERM) {
|
} else if (sig == SIGTERM) {
|
||||||
int pid = decode_pid;
|
int pid = decode_pid;
|
||||||
if (pid > 0) {
|
if (pid > 0) {
|
||||||
DEBUG("player (or child) got SIGTERM\n");
|
/* DEBUG("player (or child) got SIGTERM\n"); */
|
||||||
kill(pid, SIGCONT);
|
kill(pid, SIGCONT);
|
||||||
kill(pid, SIGTERM);
|
kill(pid, SIGTERM);
|
||||||
} else
|
} /* else
|
||||||
DEBUG("decoder (or child) got SIGTERM\n");
|
DEBUG("decoder (or child) got SIGTERM\n"); */
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,20 +130,22 @@ void directory_sigChldHandler(int pid, int status)
|
|||||||
{
|
{
|
||||||
if (directory_updatePid == pid) {
|
if (directory_updatePid == pid) {
|
||||||
if (WIFSIGNALED(status) && WTERMSIG(status) != SIGTERM) {
|
if (WIFSIGNALED(status) && WTERMSIG(status) != SIGTERM) {
|
||||||
ERROR("update process died from a "
|
/* ERROR("update process died from a "
|
||||||
"non-TERM signal: %i\n", WTERMSIG(status));
|
"non-TERM signal: %i\n", WTERMSIG(status)); */
|
||||||
} else if (!WIFSIGNALED(status)) {
|
} else if (!WIFSIGNALED(status)) {
|
||||||
switch (WEXITSTATUS(status)) {
|
switch (WEXITSTATUS(status)) {
|
||||||
case DIRECTORY_UPDATE_EXIT_UPDATE:
|
case DIRECTORY_UPDATE_EXIT_UPDATE:
|
||||||
directory_reReadDB = 1;
|
directory_reReadDB = 1;
|
||||||
DEBUG("directory_sigChldHandler: "
|
/* DEBUG("directory_sigChldHandler: "
|
||||||
"updated db\n");
|
"updated db\n"); */
|
||||||
case DIRECTORY_UPDATE_EXIT_NOUPDATE:
|
case DIRECTORY_UPDATE_EXIT_NOUPDATE:
|
||||||
DEBUG("directory_sigChldHandler: "
|
/* DEBUG("directory_sigChldHandler: "
|
||||||
"update exited succesffully\n");
|
"update exited succesffully\n"); */
|
||||||
break;
|
break;
|
||||||
|
/*
|
||||||
default:
|
default:
|
||||||
ERROR("error updating db\n");
|
ERROR("error updating db\n");
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clearUpdatePid();
|
clearUpdatePid();
|
||||||
|
@ -85,6 +85,7 @@ void player_sigChldHandler(int pid, int status)
|
|||||||
{
|
{
|
||||||
if (player_pid == pid)
|
if (player_pid == pid)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
DEBUG("SIGCHLD caused by player process\n");
|
DEBUG("SIGCHLD caused by player process\n");
|
||||||
if (WIFSIGNALED(status) &&
|
if (WIFSIGNALED(status) &&
|
||||||
WTERMSIG(status) != SIGTERM &&
|
WTERMSIG(status) != SIGTERM &&
|
||||||
@ -93,17 +94,20 @@ void player_sigChldHandler(int pid, int status)
|
|||||||
ERROR("player process died from signal: %i\n",
|
ERROR("player process died from signal: %i\n",
|
||||||
WTERMSIG(status));
|
WTERMSIG(status));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
resetPlayer();
|
resetPlayer();
|
||||||
}
|
}
|
||||||
else if (pid == getPlayerData()->playerControl.decode_pid &&
|
else if (pid == getPlayerData()->playerControl.decode_pid &&
|
||||||
player_pid <= 0)
|
player_pid <= 0)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (WIFSIGNALED(status) && WTERMSIG(status) != SIGTERM)
|
if (WIFSIGNALED(status) && WTERMSIG(status) != SIGTERM)
|
||||||
{
|
{
|
||||||
ERROR("(caught by master parent) "
|
ERROR("(caught by master parent) "
|
||||||
"decode process died from a "
|
"decode process died from a "
|
||||||
"non-TERM signal: %i\n", WTERMSIG(status));
|
"non-TERM signal: %i\n", WTERMSIG(status));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
getPlayerData()->playerControl.decode_pid = 0;
|
getPlayerData()->playerControl.decode_pid = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ static void chldSigHandler(int signal)
|
|||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
int pid;
|
int pid;
|
||||||
DEBUG("main process got SIGCHLD\n");
|
/* DEBUG("main process got SIGCHLD\n"); */
|
||||||
while (0 != (pid = wait3(&status, WNOHANG, NULL))) {
|
while (0 != (pid = wait3(&status, WNOHANG, NULL))) {
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
|
Loading…
Reference in New Issue
Block a user