From ce792263371791884f3295313c0d1dc6e5e7e2cb Mon Sep 17 00:00:00 2001 From: Kouya Heika Date: Mon, 20 Apr 2026 19:22:50 -0500 Subject: [PATCH] Set a minimum to backoff, optimize vector and main loop --- src/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 46fd5f0..650fdca 100644 --- a/src/main.c +++ b/src/main.c @@ -37,7 +37,9 @@ static int config_handler(void* user, const char* section, const char* name, con } else if (strcmp(name, "listen") == 0) { listen_port = atoi(value); } else if (strcmp(name, "backoff") == 0) { - global_backoff = atoi(value); + int val = atoi(value); + if (val < 1) val = 1; + global_backoff = val; } else { printf("Unknown configuration entry \'%s\'\n", name); } @@ -160,7 +162,7 @@ int main(int argc, char** argv) { vector_push_back(&services, &service); load_service(&service); } - vector_resize(&services, services.size); + vector_shrink_to_fit(&services); vector_clear(&tmp_services); vector_destroy(&tmp_services); @@ -174,7 +176,7 @@ int main(int argc, char** argv) { if (report_queued > 0) { report_queued = 0; report(); - } else sleep(global_backoff / 2); + } else sleep(1); } printf("\nShutting down services...\n"); fflush(stdout);