// is it time to cleanup the list? | // is it time to cleanup the list? | ||||
// cleanup every conf->interval seconds | // cleanup every conf->interval seconds | ||||
if ( dp_accountingtime + conf->interval < time(NULL) ) { | if ( dp_accountingtime + conf->interval < time(NULL) ) { | ||||
if ( conf->debug ) printf("cleanup interval\n"); | |||||
if ( conf->debug ) printf("cleanup AC\n"); | |||||
dp_accountingtime = time(NULL); | dp_accountingtime = time(NULL); | ||||
HASH_ITER(hh, accountings, ac, actmp) { | HASH_ITER(hh, accountings, ac, actmp) { | ||||
HASH_DEL(accountings, ac); | HASH_DEL(accountings, ac); |
while(1) { | while(1) { | ||||
time_t now = time(NULL); | time_t now = time(NULL); | ||||
if ( last_blacklist + DP_BL_CLEAN_INT >= now ) { | |||||
if ( last_blacklist + DP_BL_CLEAN_INT <= now ) { | |||||
dp_blacklist_cleanup(conf); | dp_blacklist_cleanup(conf); | ||||
last_blacklist=now; | last_blacklist=now; | ||||
} | } | ||||
if ( last_accounting + DP_AC_CLEAN_INT >= now ) { | |||||
if ( last_accounting + DP_AC_CLEAN_INT <= now ) { | |||||
dp_accounting_cleanup(conf); | dp_accounting_cleanup(conf); | ||||
last_accounting=now; | last_accounting=now; | ||||
} | } | ||||
if ( last_stats + conf->stats_interval >= now ) { | |||||
if ( last_stats + conf->stats_interval <= now ) { | |||||
dp_events_stats(conf); | dp_events_stats(conf); | ||||
last_stats=now; | last_stats=now; | ||||
} | } | ||||
usleep(100000); /* 100ms */ | |||||
usleep(500000); /* 100ms */ | |||||
} | } | ||||
return NULL; | return NULL; | ||||
} | } | ||||
} | } | ||||
fprintf(fh, "] }\n"); | |||||
fprintf(fh, "], \"timestamp\": %i }\n", (int)time(NULL)); | |||||
fclose(fh); | fclose(fh); | ||||