Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
SAT>IP server: fix shutdown_on_close
  • Loading branch information
perexg committed Nov 30, 2015
1 parent fc4497c commit d67e961
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/satip/rtp.c
Expand Up @@ -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) {
Expand Down
9 changes: 6 additions & 3 deletions src/satip/rtsp.c
Expand Up @@ -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];
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d67e961

Please sign in to comment.