Exemplo n.º 1
0
int32_t cs_init_log(void)
{
	if(logStarted == 0)
	{
		pthread_mutex_init(&log_mutex, NULL);

		cs_pthread_cond_init(&log_thread_sleep_cond_mutex, &log_thread_sleep_cond);

#if defined(WEBIF) || defined(MODULE_MONITOR)
		cs_lock_create(&loghistory_lock, "loghistory_lock", 5000);
#endif

		log_list = ll_create(LOG_LIST);
		pthread_attr_t attr;
		pthread_attr_init(&attr);
		pthread_attr_setstacksize(&attr, PTHREAD_STACK_SIZE);
		int32_t ret = pthread_create(&log_thread, &attr, (void *)&log_list_thread, NULL);
		if(ret)
		{
			fprintf(stderr, "ERROR: Can't create logging thread (errno=%d %s)", ret, strerror(ret));
			pthread_attr_destroy(&attr);
			cs_exit(1);
		}
		pthread_attr_destroy(&attr);
	}
	int32_t rc = 0;
	if(!cfg.disablelog) { rc = cs_open_logfiles(); }
	logStarted = 1;
	return rc;
}
Exemplo n.º 2
0
static void *reader_check(void)
{
	struct s_client *cl;
	struct s_reader *rdr;
	set_thread_name(__func__);
	cs_pthread_cond_init(__func__, &reader_check_sleep_cond_mutex, &reader_check_sleep_cond);
	while(!exit_oscam)
	{
		for(cl = first_client->next; cl ; cl = cl->next)
		{
			if(!cl->thread_active)
				{ client_check_status(cl); }
		}
		cs_readlock(__func__, &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(__func__, &readerlist_lock);
		sleepms_on_cond(__func__, &reader_check_sleep_cond_mutex, &reader_check_sleep_cond, 1000);
	}
	return NULL;
}