void log_list_thread(void) { char buf[LOG_BUF_SIZE]; log_running = 1; set_thread_name(__func__); do { log_list_queued = 0; LL_ITER it = ll_iter_create(log_list); struct s_log *log; while((log = ll_iter_next_remove(&it))) { int8_t do_flush = ll_count(log_list) == 0; //flush on writing last element cs_strncpy(buf, log->txt, LOG_BUF_SIZE); if(log->direct_log) { cs_write_log(buf, do_flush); } else { write_to_log(buf, log, do_flush); } NULLFREE(log->txt); NULLFREE(log); } if(!log_list_queued) // The list is empty, sleep until new data comes in and we are woken up sleepms_on_cond(&log_thread_sleep_cond_mutex, &log_thread_sleep_cond, 60 * 1000); } while(log_running); ll_destroy(log_list); log_list = NULL; }
static void * reader_check(void) { struct s_client *cl; struct s_reader *rdr; set_thread_name(__func__); pthread_mutex_init(&reader_check_sleep_cond_mutex, NULL); pthread_cond_init(&reader_check_sleep_cond, NULL); while (!exit_oscam) { for (cl=first_client->next; cl ; cl=cl->next) { if (!cl->thread_active) client_check_status(cl); } cs_readlock(&readerlist_lock); for (rdr=first_active_reader; rdr; rdr=rdr->next) { if (rdr->enable) { cl = rdr->client; if (!cl || cl->kill) restart_cardreader(rdr, 0); else if (!cl->thread_active) client_check_status(cl); } } cs_readunlock(&readerlist_lock); sleepms_on_cond(&reader_check_sleep_cond, &reader_check_sleep_cond_mutex, 1000); } return NULL; }