aboutsummaryrefslogtreecommitdiff
path: root/src/playerData.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2006-08-14 23:31:08 +0000
committerEric Wong <normalperson@yhbt.net>2006-08-14 23:31:08 +0000
commite5df85db158c440048af7d9f34681562cefbf7d2 (patch)
tree7e16edc34308abbc7366082a302ac6601c70f393 /src/playerData.c
parent6459b3ee29e13d5141b9e7b40bb4abce68c404be (diff)
Several bugfixes during exit found by valgrind
First, make sure we call finishPlaylist() before closeMp3Directory() since the latter will free non-SONG_TYPE_URL songs in playlist, which causes an invalid read when we try to look for SONG_TYPE_URL songs to free in finishPlaylist. Secondly, make sure our children have all exited before freeing the playerData. If we do not, slowly-delivered signals can trigger a race condition in the signal handlers of the decode and player processes which rely on getPlayerData. To avoid waitpid-ing too long (or at all), move the freePlayerData() call farther down in main() (this won't affect anything else) to give the OS a better chance to deliver signals and finish running sig handlers for terminated children. git-svn-id: https://svn.musicpd.org/mpd/trunk@4640 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/playerData.c')
-rw-r--r--src/playerData.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/playerData.c b/src/playerData.c
index df928acc..3feb46e4 100644
--- a/src/playerData.c
+++ b/src/playerData.c
@@ -21,6 +21,7 @@
#include "log.h"
#include <sys/types.h>
+#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
@@ -164,5 +165,9 @@ PlayerData *getPlayerData(void)
void freePlayerData(void)
{
+ /* We don't want to release this memory until we know our player and
+ * decoder have exited. Otherwise, their signal handlers will want to
+ * access playerData_pd and we need to keep it available for them */
+ waitpid(-1, NULL, 0);
shmdt(playerData_pd);
}