From d67e9618e7ff93e2370fa5846ef8d5e74c662df3 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 30 Nov 2015 20:40:55 +0100 Subject: [PATCH] SAT>IP server: fix shutdown_on_close --- src/satip/rtp.c | 6 ++++-- src/satip/rtsp.c | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/satip/rtp.c b/src/satip/rtp.c index 51e60fb14..58d192323 100644 --- a/src/satip/rtp.c +++ b/src/satip/rtp.c @@ -559,9 +559,11 @@ void satip_rtp_close(void *id) pthread_cond_signal(&sq->sq_cond); pthread_mutex_unlock(&sq->sq_mutex); pthread_mutex_unlock(&satip_rtp_lock); - pthread_mutex_lock(rtp->tcp_lock); + if (rtp->port == RTSP_TCP_DATA) + pthread_mutex_lock(rtp->tcp_lock); pthread_join(rtp->tid, NULL); - pthread_mutex_unlock(rtp->tcp_lock); + if (rtp->port == RTSP_TCP_DATA) + pthread_mutex_unlock(rtp->tcp_lock); udp_multisend_free(&rtp->um); mpegts_pid_done(&rtp->pids); while ((tbl = TAILQ_FIRST(&rtp->pmt_tables)) != NULL) { diff --git a/src/satip/rtsp.c b/src/satip/rtsp.c index 1196d09ee..c0e63c943 100644 --- a/src/satip/rtsp.c +++ b/src/satip/rtsp.c @@ -50,7 +50,7 @@ typedef struct session { int findex; int src; int state; - int shutdown_on_close; + http_connection_t *shutdown_on_close; int perm_lock; uint32_t nsession; char session[9]; @@ -1080,7 +1080,7 @@ rtsp_parse_cmd rs->src = src; if (cmd < 0) - rs->shutdown_on_close = 1; + rs->shutdown_on_close = hc; play: if (pids.count > 0) @@ -1460,9 +1460,12 @@ rtsp_flush_requests(http_connection_t *hc) pthread_mutex_lock(&rtsp_lock); for (rs = TAILQ_FIRST(&rtsp_sessions); rs; rs = rs_next) { rs_next = TAILQ_NEXT(rs, link); - if (rs->shutdown_on_close) { + if (rs->shutdown_on_close == hc) { rtsp_close_session(rs); rtsp_free_session(rs); + } else { + if (rs->rtp_peer_port == RTSP_TCP_DATA) + satip_rtp_close((void *)(intptr_t)rs->stream); } } pthread_mutex_unlock(&rtsp_lock); -- 2.47.3