diff --git a/rtsp.c b/rtsp.c index 47908f90..92e560e0 100644 --- a/rtsp.c +++ b/rtsp.c @@ -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); diff --git a/shairport.c b/shairport.c index 6cbe6987..ffb113cc 100644 --- a/shairport.c +++ b/shairport.c @@ -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();