]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Use shutdown() before close() and separate out the cancel requests for the timing...
authorMike Brady <mikebrady@eircom.net>
Sun, 3 Jun 2018 18:59:24 +0000 (19:59 +0100)
committerMike Brady <mikebrady@eircom.net>
Sun, 3 Jun 2018 18:59:24 +0000 (19:59 +0100)
player.c
rtp.c

index ed844f6a053e3e4fad9129e56272e82c26ad36ec..e05cebc1fe11534a6b43605ec488081b1e297e16 100644 (file)
--- a/player.c
+++ b/player.c
@@ -2335,14 +2335,19 @@ static void *player_thread_func(void *arg) {
     config.output->stop();
 
   debug(2, "Cancelling timing, control and audio threads...");
+  debug(2, "Cancel timing thread.");
   pthread_cancel(rtp_timing_thread);
-  pthread_cancel(rtp_control_thread);
-  pthread_cancel(rtp_audio_thread);
-  debug(2, "Joining terminated threads.");
+  debug(2, "Join timing thread.");
   pthread_join(rtp_timing_thread, NULL);
   debug(2, "Timing thread terminated.");
+  debug(2, "Cancel control thread.");
+  pthread_cancel(rtp_control_thread);
+  debug(2, "Join control thread.");
   pthread_join(rtp_control_thread, NULL);
   debug(2, "Control thread terminated.");
+  debug(2, "Cancel audio thread.");
+  pthread_cancel(rtp_audio_thread);
+  debug(2, "Join audio thread.");
   pthread_join(rtp_audio_thread, NULL);
   debug(2, "Audio thread terminated.");
   clear_reference_timestamp(conn);
diff --git a/rtp.c b/rtp.c
index bb28be87948433994ba4813b4b95f9ba94f49e9c..6a588b0b0b9c755fb1b28c9d109922898e80ab24 100644 (file)
--- a/rtp.c
+++ b/rtp.c
@@ -68,6 +68,9 @@ void rtp_terminate(rtsp_conn_info *conn) {
 void rtp_audio_receiver_cleanup_handler(void *arg) {
   debug(3, "Audio Receiver Cleanup.");
   rtsp_conn_info *conn = (rtsp_conn_info *)arg;
+  debug(1,"shutdown audio socket.");
+  shutdown(conn->audio_socket,SHUT_RDWR);  
+  debug(1,"close audio socket.");
   close(conn->audio_socket);
   debug(3, "Audio Receiver Cleanup Successful.");
 }
@@ -188,6 +191,9 @@ void *rtp_audio_receiver(void *arg) {
 void rtp_control_handler_cleanup_handler(void *arg) {
   debug(3, "Control Receiver Cleanup.");
   rtsp_conn_info *conn = (rtsp_conn_info *)arg;
+  debug(1,"shutdown control socket.");
+  shutdown(conn->control_socket,SHUT_RDWR);  
+  debug(1,"close control socket.");
   close(conn->control_socket);
   debug(3, "Control Receiver Cleanup Successful.");
 }
@@ -471,6 +477,9 @@ void rtp_timing_receiver_cleanup_handler(void *arg) {
   rtsp_conn_info *conn = (rtsp_conn_info *)arg;
   pthread_cancel(conn->timer_requester);
   pthread_join(conn->timer_requester, NULL);
+  debug(1,"shutdown timing socket.");
+  shutdown(conn->timing_socket,SHUT_RDWR);  
+  debug(1,"close timing socket.");
   close(conn->timing_socket);
   debug(3, "Timing Receiver Cleanup Successful.");
 }