Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
satip server: rtp - use atomic ops for satip_rtcp_run (clang sanitizer)
  • Loading branch information
perexg committed Mar 10, 2016
1 parent eadfaab commit aa4e7f0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/satip/rtp.c
Expand Up @@ -867,13 +867,13 @@ satip_rtcp_thread(void *aux)
int r, len, err;

tvhtrace("satips", "starting rtcp thread");
while (satip_rtcp_run) {
while (atomic_get(&satip_rtcp_run)) {
us = 150000;
do {
us = tvh_usleep(us);
if (us < 0)
goto end;
if (!satip_rtcp_run)
if (!atomic_get(&satip_rtcp_run))
goto end;
} while (us > 0);
pthread_mutex_lock(&satip_rtp_lock);
Expand Down Expand Up @@ -917,10 +917,10 @@ void satip_rtp_init(int boot)
pthread_mutex_init(&satip_rtp_lock, NULL);

if (boot)
satip_rtcp_run = 0;
atomic_set(&satip_rtcp_run, 0);

if (!boot && !satip_rtcp_run) {
satip_rtcp_run = 1;
if (!boot && !atomic_get(&satip_rtcp_run)) {
atomic_set(&satip_rtcp_run, 1);
tvhthread_create(&satip_rtcp_tid, NULL, satip_rtcp_thread, NULL, "satip-rtcp");
}
}
Expand All @@ -931,8 +931,8 @@ void satip_rtp_init(int boot)
void satip_rtp_done(void)
{
assert(TAILQ_EMPTY(&satip_rtp_sessions));
if (satip_rtcp_run) {
satip_rtcp_run = 0;
if (atomic_get(&satip_rtcp_run)) {
atomic_set(&satip_rtcp_run, 0);
pthread_kill(satip_rtcp_tid, SIGTERM);
pthread_join(satip_rtcp_tid, NULL);
}
Expand Down

0 comments on commit aa4e7f0

Please sign in to comment.