Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tvheadend_running -> tvheadend_is_running() change
  • Loading branch information
perexg committed Mar 8, 2016
1 parent 79808f3 commit 7b4bb43
Show file tree
Hide file tree
Showing 22 changed files with 54 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/avahi.c
Expand Up @@ -290,7 +290,7 @@ avahi_thread(void *aux)
name = NULL;
free(name2);

} while (tvheadend_running && avahi_do_restart);
} while (tvheadend_is_running() && avahi_do_restart);

return NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions src/descrambler/capmt.c
Expand Up @@ -491,7 +491,7 @@ capmt_connect(capmt_t *capmt, int i)

fd = tcp_connect(capmt->capmt_sockfile, capmt->capmt_port, NULL,
errbuf, sizeof(errbuf), 2);
if (fd < 0 && tvheadend_running) {
if (fd < 0 && tvheadend_is_running()) {
tvhlog(LOG_ERR, "capmt",
"%s: Cannot connect to %s:%i (%s); Do you have OSCam running?",
capmt_name(capmt), capmt->capmt_sockfile, capmt->capmt_port, errbuf);
Expand All @@ -512,7 +512,7 @@ capmt_connect(capmt_t *capmt, int i)
if (fd < 0 ||
connect(fd, (const struct sockaddr*)&serv_addr_un,
sizeof(serv_addr_un)) != 0) {
if (tvheadend_running)
if (tvheadend_is_running())
tvhlog(LOG_ERR, "capmt",
"%s: Cannot connect to %s (%s); Do you have OSCam running?",
capmt_name(capmt), capmt->capmt_sockfile, strerror(errno));
Expand Down
8 changes: 4 additions & 4 deletions src/descrambler/cwc.c
Expand Up @@ -946,7 +946,7 @@ cwc_read(cwc_t *cwc, void *buf, size_t len, int timeout)
r = tcp_read_timeout(cwc->cwc_fd, buf, len, timeout);
pthread_mutex_lock(&cwc->cwc_mutex);

if (r && tvheadend_running)
if (r && tvheadend_is_running())
tvhwarn("cwc", "read error %d (%s)", r, strerror(r));

if(cwc_must_break(cwc))
Expand All @@ -966,15 +966,15 @@ cwc_read_message(cwc_t *cwc, const char *state, int timeout)
int msglen, r;

if((r = cwc_read(cwc, buf, 2, timeout))) {
if (tvheadend_running)
if (tvheadend_is_running())
tvhlog(LOG_INFO, "cwc", "%s:%i: %s: Read error (header): %s",
cwc->cwc_hostname, cwc->cwc_port, state, strerror(r));
return -1;
}

msglen = (buf[0] << 8) | buf[1];
if(msglen >= CWS_NETMSGSIZE) {
if (tvheadend_running)
if (tvheadend_is_running())
tvhlog(LOG_INFO, "cwc", "%s:%i: %s: Invalid message size: %d",
cwc->cwc_hostname, cwc->cwc_port, state, msglen);
return -1;
Expand All @@ -984,7 +984,7 @@ cwc_read_message(cwc_t *cwc, const char *state, int timeout)
so just wait 1 second here */

if((r = cwc_read(cwc, cwc->cwc_buf + 2, msglen, 1000))) {
if (tvheadend_running)
if (tvheadend_is_running())
tvhlog(LOG_INFO, "cwc", "%s:%i: %s: Read error: %s",
cwc->cwc_hostname, cwc->cwc_port, state, strerror(r));
return -1;
Expand Down
2 changes: 1 addition & 1 deletion src/epggrab/otamux.c
Expand Up @@ -688,7 +688,7 @@ epggrab_ota_service_trace ( epggrab_ota_mux_t *ota,
if (mm && svc) {
mpegts_mux_nice_name(mm, buf, sizeof(buf));
tvhtrace("epggrab", "ota %s %s service %s", buf, op, svc->s_nicename);
} else if (tvheadend_running)
} else if (tvheadend_is_running())
tvhtrace("epggrab", "ota %s, problem? (%p %p)", op, mm, svc);
}

Expand Down
4 changes: 2 additions & 2 deletions src/htsp_server.c
Expand Up @@ -3061,7 +3061,7 @@ htsp_read_loop(htsp_connection_t *htsp)

/* Session main loop */

while(tvheadend_running) {
while(tvheadend_is_running()) {
readmsg:
reply = NULL;

Expand Down Expand Up @@ -3128,7 +3128,7 @@ htsp_read_loop(htsp_connection_t *htsp)
pthread_mutex_lock(&global_lock);
tcp_connection_land(tcp_id);
pthread_mutex_unlock(&global_lock);
return tvheadend_running ? r : 0;
return tvheadend_is_running() ? r : 0;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/httpc.c
Expand Up @@ -1839,7 +1839,7 @@ http_client_testsuite_run( void )
urlinit(&u2);
http_arg_init(&args);
efd = tvhpoll_create(1);
while (fgets(line, sizeof(line), fp) != NULL && tvheadend_running) {
while (fgets(line, sizeof(line), fp) != NULL && tvheadend_is_running()) {
if (line[0] == '\0')
continue;
s = line + strlen(line) - 1;
Expand Down Expand Up @@ -1954,7 +1954,7 @@ http_client_testsuite_run( void )
fprintf(stderr, "HTTPCTS Send Failed %s\n", strerror(-r));
goto fatal;
}
while (tvheadend_running) {
while (tvheadend_is_running()) {
fprintf(stderr, "HTTPCTS: Enter Poll\n");
r = tvhpoll_wait(efd, &ev, 1, -1);
fprintf(stderr, "HTTPCTS: Leave Poll: %i (%s)\n", r, r < 0 ? val2str(-r, ERRNO_tab) : "OK");
Expand Down
2 changes: 1 addition & 1 deletion src/idnode.c
Expand Up @@ -1732,7 +1732,7 @@ idnode_notify ( idnode_t *in, const char *action )
char ubuf[UUID_HEX_SIZE];
const char *uuid = idnode_uuid_as_str(in, ubuf);

if (!tvheadend_running)
if (!tvheadend_is_running())
return;

while (ic) {
Expand Down
4 changes: 2 additions & 2 deletions src/imagecache.c
Expand Up @@ -295,7 +295,7 @@ imagecache_image_fetch ( imagecache_image_t *img )
if (r < 0)
goto error_lock;

while (tvheadend_running) {
while (tvheadend_is_running()) {
r = tvhpoll_wait(efd, &ev, 1, -1);
if (r < 0)
break;
Expand Down Expand Up @@ -341,7 +341,7 @@ imagecache_thread ( void *p )
imagecache_image_t *img;

pthread_mutex_lock(&global_lock);
while (tvheadend_running) {
while (tvheadend_is_running()) {

/* Check we're enabled */
if (!imagecache_conf.enabled) {
Expand Down
4 changes: 2 additions & 2 deletions src/input/mpegts/iptv/iptv.c
Expand Up @@ -457,10 +457,10 @@ iptv_input_thread ( void *aux )
iptv_mux_t *im;
tvhpoll_event_t ev;

while ( tvheadend_running ) {
while ( tvheadend_is_running() ) {
nfds = tvhpoll_wait(iptv_poll, &ev, 1, -1);
if ( nfds < 0 ) {
if (tvheadend_running && !ERRNO_AGAIN(errno)) {
if (tvheadend_is_running() && !ERRNO_AGAIN(errno)) {
tvhlog(LOG_ERR, "iptv", "poll() error %s, sleeping 1 second",
strerror(errno));
sleep(1);
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/linuxdvb/linuxdvb_ca.c
Expand Up @@ -700,7 +700,7 @@ linuxdvb_ca_en50221_thread ( void *aux )

lca->lca_tc = en50221_tl_new_tc(lca->lca_tl, slot_id);

while (tvheadend_running && lca->lca_en50221_thread_running) {
while (tvheadend_is_running() && lca->lca_en50221_thread_running) {
int error;
if ((error = en50221_tl_poll(lca->lca_tl)) != 0) {
if (error != lasterror) {
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/linuxdvb/linuxdvb_frontend.c
Expand Up @@ -1198,7 +1198,7 @@ linuxdvb_frontend_input_thread ( void *aux )
linuxdvb_update_pids(lfe, name, &tuned, pids, ARRAY_SIZE(pids));

/* Read */
while (tvheadend_running) {
while (tvheadend_is_running()) {
nfds = tvhpoll_wait(efd, ev, 1, 150);
if (nfds == 0) { /* timeout */
if (nodata == 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/input/mpegts/satip/satip.c
Expand Up @@ -1220,7 +1220,7 @@ satip_discovery_static_timer_cb(void *aux)
{
int i;

if (!tvheadend_running)
if (!tvheadend_is_running())
return;
for (i = 0; i < satip_static_clients->num; i++)
satip_discovery_static(satip_static_clients->str[i]);
Expand All @@ -1230,7 +1230,7 @@ satip_discovery_static_timer_cb(void *aux)
static void
satip_discovery_timer_cb(void *aux)
{
if (!tvheadend_running)
if (!tvheadend_is_running())
return;
if (!upnp_running) {
mtimer_arm_rel(&satip_discovery_timer, satip_discovery_timer_cb,
Expand Down
6 changes: 3 additions & 3 deletions src/input/mpegts/satip/satip_frontend.c
Expand Up @@ -1226,7 +1226,7 @@ satip_frontend_input_thread ( void *aux )

nfds = tvhpoll_wait(efd, ev, 1, rtsp ? 50 : -1);

if (!tvheadend_running) { exit_flag = 1; goto done; }
if (!tvheadend_is_running()) { exit_flag = 1; goto done; }
if (rtsp && getfastmonoclock() - u64_2 > 50000) /* 50ms */
satip_frontend_close_rtsp(lfe, buf, efd, &rtsp);
if (nfds <= 0) continue;
Expand Down Expand Up @@ -1349,7 +1349,7 @@ satip_frontend_input_thread ( void *aux )
tc = 1;
nfds = tvhpoll_wait(efd, ev, 1, r);

if (!tvheadend_running) { exit_flag = 1; goto done; }
if (!tvheadend_is_running()) { exit_flag = 1; goto done; }
if (nfds < 0) continue;
if (nfds == 0) break;

Expand Down Expand Up @@ -1463,7 +1463,7 @@ satip_frontend_input_thread ( void *aux )

nfds = tvhpoll_wait(efd, ev, 1, ms);

if (!tvheadend_running || exit_flag) {
if (!tvheadend_is_running() || exit_flag) {
exit_flag = 1;
running = 0;
if (reply++ > 5)
Expand Down
6 changes: 3 additions & 3 deletions src/input/mpegts/tvhdhomerun/tvhdhomerun.c
Expand Up @@ -348,7 +348,7 @@ tvhdhomerun_device_discovery_thread( void *aux )
struct hdhomerun_discover_device_t result_list[MAX_HDHOMERUN_DEVICES];
int numDevices, brk;

while (tvheadend_running) {
while (tvheadend_is_running()) {

numDevices =
hdhomerun_discover_find_devices_custom(0,
Expand All @@ -364,7 +364,7 @@ tvhdhomerun_device_discovery_thread( void *aux )
if ( cDev->device_type == HDHOMERUN_DEVICE_TYPE_TUNER ) {
pthread_mutex_lock(&global_lock);
if ( !tvhdhomerun_device_find(cDev->device_id) &&
tvheadend_running ) {
tvheadend_is_running() ) {
tvhlog(LOG_INFO, "tvhdhomerun","Found HDHomerun device %08x with %d tuners",
cDev->device_id, cDev->tuner_count);
tvhdhomerun_device_create(cDev);
Expand All @@ -376,7 +376,7 @@ tvhdhomerun_device_discovery_thread( void *aux )

pthread_mutex_lock(&tvhdhomerun_discovery_lock);
brk = 0;
if (tvheadend_running) {
if (tvheadend_is_running()) {
brk = tvh_cond_timedwait(&tvhdhomerun_discovery_cond,
&tvhdhomerun_discovery_lock,
mclk() + sec2mono(15));
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c
Expand Up @@ -172,7 +172,7 @@ tvhdhomerun_frontend_input_thread ( void *aux )

/* TODO: flush buffer? */

while(tvheadend_running) {
while(tvheadend_is_running()) {
nfds = tvhpoll_wait(efd, ev, 1, -1);

if (nfds < 1) continue;
Expand Down
12 changes: 6 additions & 6 deletions src/main.c
Expand Up @@ -209,7 +209,7 @@ doexit(int x)
if (pthread_self() != main_tid)
pthread_kill(main_tid, SIGTERM);
pthread_cond_signal(&gtimer_cond);
tvheadend_running = 0;
atomic_set(&tvheadend_running, 0);
signal(x, doexit);
}

Expand Down Expand Up @@ -442,7 +442,7 @@ tasklet_thread ( void *aux )
tvhtread_renice(20);

pthread_mutex_lock(&tasklet_lock);
while (tvheadend_running) {
while (tvheadend_is_running()) {
tsk = TAILQ_FIRST(&tasklets);
if (tsk == NULL) {
tvh_cond_wait(&tasklet_cond, &tasklet_lock);
Expand Down Expand Up @@ -546,7 +546,7 @@ mdispatch_clock_update(void)
static void *
mtimer_tick_thread(void *aux)
{
while (tvheadend_running) {
while (tvheadend_is_running()) {
/* update clocks each 10x in one second */
atomic_set_s64(&__mdispatch_clock, getmonoclock());
tvh_safe_usleep(100000);
Expand All @@ -569,7 +569,7 @@ mtimer_thread(void *aux)
const char *fcn;
#endif

while (tvheadend_running) {
while (tvheadend_is_running()) {
now = mdispatch_clock_update();

/* Global monoclock timers */
Expand Down Expand Up @@ -642,7 +642,7 @@ mainloop(void)
const char *fcn;
#endif

while (tvheadend_running) {
while (tvheadend_is_running()) {
now = gdispatch_clock_update();

/* Global timers */
Expand Down Expand Up @@ -1088,7 +1088,7 @@ main(int argc, char **argv)
umask(0);
}

tvheadend_running = 1;
atomic_set(&tvheadend_running, 1);

/* Start log thread (must be done post fork) */
tvhlog_start();
Expand Down
4 changes: 2 additions & 2 deletions src/notify.c
Expand Up @@ -55,7 +55,7 @@ notify_delayed(const char *id, const char *event, const char *action)
htsmsg_t *m = NULL, *e = NULL;
htsmsg_field_t *f;

if (!tvheadend_running)
if (!tvheadend_is_running())
return;

pthread_mutex_lock(&notify_mutex);
Expand Down Expand Up @@ -88,7 +88,7 @@ notify_thread ( void *p )

pthread_mutex_lock(&notify_mutex);

while (tvheadend_running) {
while (tvheadend_is_running()) {

/* Get queue */
if (!notify_queue) {
Expand Down
2 changes: 1 addition & 1 deletion src/service.c
Expand Up @@ -1448,7 +1448,7 @@ service_saver(void *aux)

pthread_mutex_lock(&pending_save_mutex);

while(tvheadend_running) {
while(tvheadend_is_running()) {

if((t = TAILQ_FIRST(&pending_save_queue)) == NULL) {
tvh_cond_wait(&pending_save_cond, &pending_save_mutex);
Expand Down
14 changes: 7 additions & 7 deletions src/service_mapper.c
Expand Up @@ -304,7 +304,7 @@ service_mapper_thread ( void *aux )

pthread_mutex_lock(&global_lock);

while (tvheadend_running) {
while (tvheadend_is_running()) {

/* Wait for work */
while (!(smi = TAILQ_FIRST(&service_mapper_queue))) {
Expand All @@ -313,10 +313,10 @@ service_mapper_thread ( void *aux )
tvhinfo("service_mapper", "idle");
}
tvh_cond_wait(&service_mapper_cond, &global_lock);
if (!tvheadend_running)
if (!tvheadend_is_running())
break;
}
if (!tvheadend_running)
if (!tvheadend_is_running())
break;
s = smi->s;
service_mapper_remove(s);
Expand Down Expand Up @@ -350,15 +350,15 @@ service_mapper_thread ( void *aux )
/* Wait */
run = 1;
pthread_mutex_lock(&sq->sq_mutex);
while(tvheadend_running && run) {
while(tvheadend_is_running() && run) {

/* Wait for message */
while((sm = TAILQ_FIRST(&sq->sq_queue)) == NULL) {
tvh_cond_wait(&sq->sq_cond, &sq->sq_mutex);
if (!tvheadend_running)
if (!tvheadend_is_running())
break;
}
if (!tvheadend_running)
if (!tvheadend_is_running())
break;

streaming_queue_remove(sq, sm);
Expand All @@ -382,7 +382,7 @@ service_mapper_thread ( void *aux )
streaming_msg_free(sm);
pthread_mutex_lock(&sq->sq_mutex);
}
if (!tvheadend_running)
if (!tvheadend_is_running())
break;

streaming_queue_clear(&sq->sq_queue);
Expand Down

0 comments on commit 7b4bb43

Please sign in to comment.