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
This commit is contained in:
parent
6459b3ee29
commit
e5df85db15
@ -477,14 +477,13 @@ int main(int argc, char *argv[])
|
|||||||
playerKill();
|
playerKill();
|
||||||
freeAllInterfaces();
|
freeAllInterfaces();
|
||||||
closeAllListenSockets();
|
closeAllListenSockets();
|
||||||
|
finishPlaylist();
|
||||||
|
|
||||||
start = clock();
|
start = clock();
|
||||||
closeMp3Directory();
|
closeMp3Directory();
|
||||||
DEBUG("closeMp3Directory took %f seconds\n",
|
DEBUG("closeMp3Directory took %f seconds\n",
|
||||||
((float)(clock()-start))/CLOCKS_PER_SEC);
|
((float)(clock()-start))/CLOCKS_PER_SEC);
|
||||||
|
|
||||||
finishPlaylist();
|
|
||||||
freePlayerData();
|
|
||||||
finishNormalization();
|
finishNormalization();
|
||||||
finishAudioDriver();
|
finishAudioDriver();
|
||||||
finishAudioConfig();
|
finishAudioConfig();
|
||||||
@ -495,6 +494,7 @@ int main(int argc, char *argv[])
|
|||||||
finishInputPlugins();
|
finishInputPlugins();
|
||||||
cleanUpPidFile();
|
cleanUpPidFile();
|
||||||
finishConf();
|
finishConf();
|
||||||
|
freePlayerData();
|
||||||
|
|
||||||
close_log_files();
|
close_log_files();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
@ -124,8 +124,8 @@ int playerInit(void)
|
|||||||
|
|
||||||
closeAllListenSockets();
|
closeAllListenSockets();
|
||||||
freeAllInterfaces();
|
freeAllInterfaces();
|
||||||
closeMp3Directory();
|
|
||||||
finishPlaylist();
|
finishPlaylist();
|
||||||
|
closeMp3Directory();
|
||||||
finishPermissions();
|
finishPermissions();
|
||||||
finishCommands();
|
finishCommands();
|
||||||
finishVolume();
|
finishVolume();
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -164,5 +165,9 @@ PlayerData *getPlayerData(void)
|
|||||||
|
|
||||||
void freePlayerData(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);
|
shmdt(playerData_pd);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user