From 6c23d14cf3f508eba1ab883557ff93d53b9c15e6 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Mon, 23 May 2022 17:12:21 +0100 Subject: [PATCH] Fix an odd bug that could arise while exiting the program, causing it to crash on exit. --- rtsp.c | 3 +-- shairport.c | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rtsp.c b/rtsp.c index ba804fac..526c85d0 100644 --- a/rtsp.c +++ b/rtsp.c @@ -5005,7 +5005,6 @@ void rtsp_listen_loop_cleanup_handler(__attribute__((unused)) void *arg) { debug(2, "rtsp_listen_loop_cleanup_handler called."); cancel_all_RTSP_threads(unspecified_stream_category, 0); // kill all RTSP listeners int *sockfd = (int *)arg; - mdns_unregister(); if (sockfd) { int i; for (i = 1; i <= sockfd[0]; i++) { @@ -5130,7 +5129,7 @@ void *rtsp_listen_loop(__attribute((unused)) void *arg) { t2 = secondary_txt_records; // second set of text records in AirPlay 2 only #endif build_bonjour_strings(NULL); // no conn yet - mdns_register(t1, t2); + mdns_register(t1, t2); // note that the dacp thread could still be using the mdns stuff after all player threads have been terminated, so mdns_unregister can't be in the rtsp_listen_loop cleanup. pthread_setcancelstate(oldState, NULL); int acceptfd; diff --git a/shairport.c b/shairport.c index 099515e8..4e25c262 100644 --- a/shairport.c +++ b/shairport.c @@ -1619,6 +1619,7 @@ void exit_function() { debug(1, "exit_function libdaemon exit"); } #else + mdns_unregister(); // once the dacp handler is done and all player threrads are done it should be safe debug(1, "normal exit"); #endif } else {