Ejemplo n.º 1
0
void wd_trackers_schedule(void) {
	if(wd_settings._register) {
		wi_timer_schedule(wd_trackers_register_timer);
		wi_timer_schedule(wd_trackers_update_timer);
	} else {
		wi_timer_invalidate(wd_trackers_register_timer);
		wi_timer_invalidate(wd_trackers_update_timer);
	}
}
Ejemplo n.º 2
0
static void wd_transfer_create_timer(wd_transfer_t *transfer) {
	transfer->timer = wi_timer_init_with_function(wi_timer_alloc(),
												  wd_transfer_expire_timer,
												  WD_TRANSFERS_WAITING_INTERVAL,
												  false);
	wi_timer_set_data(transfer->timer, transfer);
	wi_timer_schedule(transfer->timer);
	
	wi_retain(transfer);
}
Ejemplo n.º 3
0
static void _wi_test_timer_function(wi_timer_t *timer) {
    wi_uinteger_t		*hits;

    hits = wi_timer_data(timer);

    if(++(*hits) == 5)
        wi_timer_invalidate(timer);
    else
        wi_timer_schedule(timer);
}
Ejemplo n.º 4
0
static void _wi_test_timer_function(wi_timer_t *timer) {
	wi_condition_lock_lock(_wi_test_timer_lock);
	
	if(++_wi_test_timer_hits == 5) {
		wi_timer_invalidate(timer);
		wi_condition_lock_unlock_with_condition(_wi_test_timer_lock, 1);
	} else {
		wi_timer_schedule(timer);
		wi_condition_lock_unlock_with_condition(_wi_test_timer_lock, 0);
	}
}
Ejemplo n.º 5
0
void wi_test_timer(void) {
#ifdef WI_PTHREADS
    wi_timer_t		*timer;

    timer = wi_autorelease(wi_timer_init_with_function(wi_timer_alloc(), _wi_test_timer_function, 0.01, false));
    wi_timer_set_data(timer, &_wi_test_timer_hits);
    wi_timer_schedule(timer);

    wi_thread_sleep(0.1);

    WI_TEST_ASSERT_EQUALS(_wi_test_timer_hits, 5U, "");
#endif
}
Ejemplo n.º 6
0
void wd_banlist_add_temporary_ban_for_ip(wi_string_t *ip) {
	wd_tempban_t	*tempban;
	
	tempban = wd_tempban_with_ip(ip);
	tempban->timer = wi_timer_init_with_function(wi_timer_alloc(),
										wd_tempban_expire_timer,
										wd_settings.bantime,
										false);

	wi_timer_set_data(tempban->timer, tempban);
	wi_timer_schedule(tempban->timer);
	
	wi_dictionary_wrlock(wd_tempbans);
	wi_mutable_dictionary_set_data_for_key(wd_tempbans, tempban, tempban->ip);
	wi_dictionary_unlock(wd_tempbans);
}
Ejemplo n.º 7
0
void wi_test_timer(void) {
#ifdef WI_PTHREADS
	wi_timer_t		*timer;
	
	_wi_test_timer_lock = wi_autorelease(wi_condition_lock_init_with_condition(wi_condition_lock_alloc(), 0));
	
	timer = wi_autorelease(wi_timer_init_with_function(wi_timer_alloc(), _wi_test_timer_function, 0.001, false));
	wi_timer_schedule(timer);
	
	if(wi_condition_lock_lock_when_condition(_wi_test_timer_lock, 1, 1.0)) {
		WI_TEST_ASSERT_EQUALS(_wi_test_timer_hits, 5U, "");
		wi_condition_lock_unlock(_wi_test_timer_lock);
	} else {
		WI_TEST_FAIL("Timed out waiting for timer, currently at %u %s",
			_wi_test_timer_hits, _wi_test_timer_hits == 1 ? "hit" : "hits");
	}
#endif
}
Ejemplo n.º 8
0
void wd_users_schedule(void) {
	wi_timer_schedule(wd_users_timer);
}
Ejemplo n.º 9
0
void wd_schedule_transfers(void) {
	wi_timer_schedule(wd_transfers_timer);
}
Ejemplo n.º 10
0
void wt_schedule_servers(void) {
	wi_timer_schedule(wt_servers_timer);
}