diff --git a/src/main.c b/src/main.c index 43311b3a7..6c175fbd7 100644 --- a/src/main.c +++ b/src/main.c @@ -477,14 +477,13 @@ int main(int argc, char *argv[]) playerKill(); freeAllInterfaces(); closeAllListenSockets(); + finishPlaylist(); start = clock(); closeMp3Directory(); DEBUG("closeMp3Directory took %f seconds\n", ((float)(clock()-start))/CLOCKS_PER_SEC); - finishPlaylist(); - freePlayerData(); finishNormalization(); finishAudioDriver(); finishAudioConfig(); @@ -495,6 +494,7 @@ int main(int argc, char *argv[]) finishInputPlugins(); cleanUpPidFile(); finishConf(); + freePlayerData(); close_log_files(); return EXIT_SUCCESS; diff --git a/src/player.c b/src/player.c index 527e28aff..c24424c44 100644 --- a/src/player.c +++ b/src/player.c @@ -124,8 +124,8 @@ int playerInit(void) closeAllListenSockets(); freeAllInterfaces(); - closeMp3Directory(); finishPlaylist(); + closeMp3Directory(); finishPermissions(); finishCommands(); finishVolume(); diff --git a/src/playerData.c b/src/playerData.c index df928acc4..3feb46e45 100644 --- a/src/playerData.c +++ b/src/playerData.c @@ -21,6 +21,7 @@ #include "log.h" #include +#include #include #include #include @@ -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); }