diff --git a/src/denm.c b/src/denm.c index fcc0619..94fa81b 100644 --- a/src/denm.c +++ b/src/denm.c @@ -396,6 +396,9 @@ void* den_service(void *fc) { den->events[i] = calloc(1, sizeof(event_t)); } + uint32_t sleep4us = 5e5; + uint32_t sleep_count = 0; + while (!facilities->exit) { clock_gettime(CLOCK_REALTIME, &systemtime); now = (long)(systemtime.tv_sec * 1000 + systemtime.tv_nsec / 1E6); @@ -433,12 +436,16 @@ void* den_service(void *fc) { } } } - - syslog_info("[facilities] [den] events :: [ %d active | %d cancelled | %d negated ]", den->n_active_events, den->n_cancelled_events, den->n_negated_events); + + if (sleep4us * sleep_count > 5e6) { /* Print info every 5 seconds */ + syslog_info("[facilities] [den] events :: [ %d active | %d cancelled | %d negated ]", den->n_active_events, den->n_cancelled_events, den->n_negated_events); + sleep_count = 0; + } pthread_mutex_unlock(&den->lock); - usleep(1000000); + ++sleep_count; + usleep(sleep4us); } return NULL; diff --git a/src/infrastructure.c b/src/infrastructure.c index fc96132..15483bc 100644 --- a/src/infrastructure.c +++ b/src/infrastructure.c @@ -525,6 +525,9 @@ void* infrastructure_service(void *fc) { infrastructure->services[i] = calloc(1, sizeof(service_t)); } + uint32_t sleep4us = 5e5; + uint32_t sleep_count = 0; + while (!facilities->exit) { clock_gettime(CLOCK_REALTIME, &systemtime); now = (long)(systemtime.tv_sec * 1000 + systemtime.tv_nsec / 1E6); @@ -568,12 +571,16 @@ void* infrastructure_service(void *fc) { } } } - - syslog_info("[facilities] [infrastructure] services :: [ %d active | %d awaiting | %d cancelled | %d negated ]", infrastructure->n_active_services - n_awaiting_services, n_awaiting_services, infrastructure->n_cancelled_services, infrastructure->n_negated_services); - + + if (sleep_count * sleep4us > 5e6) { /* Print info every 5 seconds */ + syslog_info("[facilities] [infrastructure] services :: [ %d active | %d awaiting | %d cancelled | %d negated ]", infrastructure->n_active_services - n_awaiting_services, n_awaiting_services, infrastructure->n_cancelled_services, infrastructure->n_negated_services); + sleep_count = 0; + } + pthread_mutex_unlock(&infrastructure->lock); - usleep(1000000); + ++sleep_count; + usleep(sleep4us); } return NULL;