Exemple #1
0
// type is ignored
int setitimer(int type, struct itimerval *in, struct itimerval *out) {
	static const struct timeval zero;
	static int atexit_done;

	if (out != NULL)
		return errno = EINVAL;
	if (!is_timeval_eq(&in->it_interval, &zero) &&
	    !is_timeval_eq(&in->it_interval, &in->it_value))
		return errno = EINVAL;

	if (timer_thread)
		stop_timer_thread();

	if (is_timeval_eq(&in->it_value, &zero) &&
	    is_timeval_eq(&in->it_interval, &zero))
		return 0;

	timer_interval = in->it_value.tv_sec * 1000 + in->it_value.tv_usec / 1000;
	one_shot = is_timeval_eq(&in->it_interval, &zero);
	if (!atexit_done) {
		atexit(stop_timer_thread);
		atexit_done = 1;
	}
	return start_timer_thread();
}
Exemple #2
0
c_bool_t stop_sync ( )
{
    if ( stop_monitor_thread () != 0 )
    {
        return false;
    }
    if ( stop_check_db_thread () != 0 )
    {
        return false;
    }
    if ( stop_timer_thread () != 0 )
    {
        return false;
    }
    if ( stop_read_log_thread () != 0 )
    {
        return false;
    }
    delete tp;
    return true;
}