From: Jaroslav Kysela Date: Tue, 30 Jan 2018 17:50:39 +0000 (+0100) Subject: capmt: more atomic changes (clang sanitizer) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7060b175dfc5d1a3a7d95c6d31cd9d08014448df;p=thirdparty%2Ftvheadend.git capmt: more atomic changes (clang sanitizer) --- diff --git a/src/descrambler/caclient.c b/src/descrambler/caclient.c index 58462b7bc..7a8f08de4 100644 --- a/src/descrambler/caclient.c +++ b/src/descrambler/caclient.c @@ -380,10 +380,8 @@ caclient_caid_update void caclient_set_status(caclient_t *cac, caclient_status_t status) { - if (cac->cac_status != status) { - cac->cac_status = status; + if (atomic_exchange(&cac->cac_status, status) != status) idnode_lnotify_changed(&cac->cac_id); - } } const char * diff --git a/src/descrambler/capmt.c b/src/descrambler/capmt.c index a20ce765b..0ccaaf5a4 100644 --- a/src/descrambler/capmt.c +++ b/src/descrambler/capmt.c @@ -947,11 +947,10 @@ capmt_set_filter(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) filter_index >= MAX_FILTER || pid > 8191) return; + pthread_mutex_lock(&capmt->capmt_mutex); cf = &capmt->capmt_demuxes.filters[demux_index]; if (cf->max && cf->adapter != adapter) - return; - - pthread_mutex_lock(&capmt->capmt_mutex); + goto end; /* ECM messages have the higher priority */ t = NULL; @@ -1010,6 +1009,7 @@ cont: capmt->capmt_demuxes.max = demux_index + 1; if (cf->max <= filter_index) cf->max = filter_index + 1; +end: pthread_mutex_unlock(&capmt->capmt_mutex); } @@ -1817,6 +1817,7 @@ capmt_thread(void *aux) while (atomic_get(&capmt->capmt_running)) { fatal = 0; + pthread_mutex_lock(&capmt->capmt_mutex); for (i = 0; i < MAX_CA; i++) { ca = &capmt->capmt_adapters[i]; ca->ca_number = i; @@ -1835,6 +1836,7 @@ capmt_thread(void *aux) capmt->capmt_sock_reconnect[i] = 0; } capmt_init_demuxes(capmt); + pthread_mutex_unlock(&capmt->capmt_mutex); /* Accessible */ if (capmt->capmt_sockfile && capmt->capmt_oscam != CAPMT_OSCAM_TCP &&