Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
subscriptions: improve s_descramble_info locking (clang sanitizer)
  • Loading branch information
perexg committed Mar 10, 2016
1 parent 571744f commit 145ad1f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/descrambler/descrambler.c
Expand Up @@ -335,10 +335,14 @@ static void
descrambler_notify_deliver( mpegts_service_t *t, descramble_info_t *di, int locked )
{
streaming_message_t *sm;
int r;

pthread_mutex_lock(&t->s_stream_mutex);
if (!t->s_descramble_info)
t->s_descramble_info = calloc(1, sizeof(*di));
if (memcmp(t->s_descramble_info, di, sizeof(*di)) == 0) {
r = memcmp(t->s_descramble_info, di, sizeof(*di));
pthread_mutex_unlock(&t->s_stream_mutex);
if (r == 0) { /* identical */
free(di);
return;
}
Expand Down
7 changes: 5 additions & 2 deletions src/subscriptions.c
Expand Up @@ -893,6 +893,7 @@ subscription_create_msg(th_subscription_t *s, const char *lang)
{
htsmsg_t *m = htsmsg_create_map();
descramble_info_t *di;
service_t *t;
profile_t *pro;
char buf[256];

Expand Down Expand Up @@ -936,9 +937,10 @@ subscription_create_msg(th_subscription_t *s, const char *lang)
if(s->ths_channel != NULL)
htsmsg_add_str(m, "channel", channel_get_name(s->ths_channel));

if(s->ths_service != NULL) {
htsmsg_add_str(m, "service", s->ths_service->s_nicename ?: "");
if((t = s->ths_service) != NULL) {
htsmsg_add_str(m, "service", t->s_nicename ?: "");

pthread_mutex_lock(&t->s_stream_mutex);
if ((di = s->ths_service->s_descramble_info) != NULL) {
if (di->caid == 0 && di->ecmtime == 0) {
snprintf(buf, sizeof(buf), N_("Failed"));
Expand All @@ -949,6 +951,7 @@ subscription_create_msg(th_subscription_t *s, const char *lang)
}
htsmsg_add_str(m, "descramble", buf);
}
pthread_mutex_unlock(&t->s_stream_mutex);

if (s->ths_prch != NULL) {
pro = s->ths_prch->prch_pro;
Expand Down

0 comments on commit 145ad1f

Please sign in to comment.