fix potential deadlock while shutting down

This commit is contained in:
James Laird
2013-04-01 20:08:28 +11:00
parent 04b142dbe3
commit 86e94064c0
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ static inline int rtsp_playing(void) {
static void rtsp_take_player(void) {
if (pthread_mutex_trylock(&playing_mutex)) {
debug("another thread is playing, shutting it down\n");
debug("shutting down playing thread\n");
// XXX minor race condition between please_shutdown and signal delivery
please_shutdown = 1;
pthread_kill(playing_thread, SIGUSR1);
+4 -1
View File
@@ -4,8 +4,11 @@
#include "rtsp.h"
#include "mdns.h"
static int shutting_down = 0;
static void shutdown(void) {
if (shutting_down)
return;
shutting_down = 1;
printf("Shutting down...\n");
mdns_unregister();
rtsp_shutdown_stream();