capmt->capmt_sock[i] = -1;
- if (!capmt->capmt_running)
+ if (!atomic_get(&capmt->capmt_running))
return -1;
if (capmt->capmt_oscam == CAPMT_OSCAM_TCP ||
i = 0;
adapter = -1;
- while (capmt->capmt_running) {
+ while (atomic_get(&capmt->capmt_running)) {
nfds = tvhpoll_wait(capmt->capmt_poll, ev, MAX_CA + 1, 500);
}
tvhtrace("capmt", "%s: thread received shutdown", capmt_name(capmt));
- capmt->capmt_running = 0;
+ atomic_set(&capmt->capmt_running, 0);
continue;
}
capmt_poll_add(capmt, capmt->capmt_pipe.rd, 0);
capmt_poll_add(capmt, capmt->capmt_sock[0], 1);
- while (capmt->capmt_running) {
+ while (atomic_get(&capmt->capmt_running)) {
nfds = tvhpoll_wait(capmt->capmt_poll, &ev, 1, 500);
}
tvhtrace("capmt", "%s: thread received shutdown", capmt_name(capmt));
- capmt->capmt_running = 0;
+ atomic_set(&capmt->capmt_running, 0);
continue;
}
capmt_notify_server(capmt, NULL, 1);
- while (capmt->capmt_running) {
+ while (atomic_get(&capmt->capmt_running)) {
if (capmt->capmt_sock[0] < 0)
break;
tvhlog(LOG_INFO, "capmt", "%s active", capmt_name(capmt));
- while (capmt->capmt_running) {
+ while (atomic_get(&capmt->capmt_running)) {
fatal = 0;
for (i = 0; i < MAX_CA; i++) {
ca = &capmt->capmt_adapters[i];
pthread_mutex_lock(&capmt->capmt_mutex);
- while(capmt->capmt_running && capmt->cac_enabled == 0)
+ while(atomic_get(&capmt->capmt_running) && capmt->cac_enabled == 0)
tvh_cond_wait(&capmt->capmt_cond, &capmt->capmt_mutex);
pthread_mutex_unlock(&capmt->capmt_mutex);
- if (!capmt->capmt_running) continue;
+ if (!atomic_get(&capmt->capmt_running)) continue;
/* open connection to camd.socket */
capmt_connect(capmt, 0);
close(capmt->capmt_adapters[i].ca_sock);
}
- if (capmt->capmt_reconfigure) {
- capmt->capmt_reconfigure = 0;
- capmt->capmt_running = 1;
+ if (atomic_get(&capmt->capmt_reconfigure)) {
+ atomic_set(&capmt->capmt_reconfigure, 0);
+ atomic_set(&capmt->capmt_running, 1);
pthread_mutex_unlock(&capmt->capmt_mutex);
continue;
}
- if (!capmt->capmt_running) {
+ if (!atomic_get(&capmt->capmt_running)) {
pthread_mutex_unlock(&capmt->capmt_mutex);
continue;
}
caclient_set_status(cac, CACLIENT_STATUS_NONE);
return;
}
- if (!capmt->capmt_running) {
- capmt->capmt_running = 1;
- capmt->capmt_reconfigure = 0;
+ if (!atomic_get(&capmt->capmt_running)) {
+ atomic_set(&capmt->capmt_running, 1);
+ atomic_set(&capmt->capmt_reconfigure, 0);
tvhthread_create(&capmt->capmt_tid, NULL, capmt_thread, capmt, "capmt");
return;
}
pthread_mutex_lock(&capmt->capmt_mutex);
- capmt->capmt_reconfigure = 1;
+ atomic_set(&capmt->capmt_reconfigure, 1);
tvh_cond_signal(&capmt->capmt_cond, 0);
pthread_mutex_unlock(&capmt->capmt_mutex);
tvh_write(capmt->capmt_pipe.wr, "", 1);
} else {
- if (!capmt->capmt_running)
+ if (!atomic_get(&capmt->capmt_running))
return;
pthread_mutex_lock(&capmt->capmt_mutex);
- capmt->capmt_running = 0;
- capmt->capmt_reconfigure = 0;
+ atomic_set(&capmt->capmt_running, 0);
+ atomic_set(&capmt->capmt_reconfigure, 0);
tvh_cond_signal(&capmt->capmt_cond, 0);
tid = capmt->capmt_tid;
pthread_mutex_unlock(&capmt->capmt_mutex);