Set a minimum to backoff, optimize vector and main loop
This commit is contained in:
@@ -37,7 +37,9 @@ static int config_handler(void* user, const char* section, const char* name, con
|
|||||||
} else if (strcmp(name, "listen") == 0) {
|
} else if (strcmp(name, "listen") == 0) {
|
||||||
listen_port = atoi(value);
|
listen_port = atoi(value);
|
||||||
} else if (strcmp(name, "backoff") == 0) {
|
} else if (strcmp(name, "backoff") == 0) {
|
||||||
global_backoff = atoi(value);
|
int val = atoi(value);
|
||||||
|
if (val < 1) val = 1;
|
||||||
|
global_backoff = val;
|
||||||
} else {
|
} else {
|
||||||
printf("Unknown configuration entry \'%s\'\n", name);
|
printf("Unknown configuration entry \'%s\'\n", name);
|
||||||
}
|
}
|
||||||
@@ -160,7 +162,7 @@ int main(int argc, char** argv) {
|
|||||||
vector_push_back(&services, &service);
|
vector_push_back(&services, &service);
|
||||||
load_service(&service);
|
load_service(&service);
|
||||||
}
|
}
|
||||||
vector_resize(&services, services.size);
|
vector_shrink_to_fit(&services);
|
||||||
vector_clear(&tmp_services);
|
vector_clear(&tmp_services);
|
||||||
vector_destroy(&tmp_services);
|
vector_destroy(&tmp_services);
|
||||||
|
|
||||||
@@ -174,7 +176,7 @@ int main(int argc, char** argv) {
|
|||||||
if (report_queued > 0) {
|
if (report_queued > 0) {
|
||||||
report_queued = 0;
|
report_queued = 0;
|
||||||
report();
|
report();
|
||||||
} else sleep(global_backoff / 2);
|
} else sleep(1);
|
||||||
}
|
}
|
||||||
printf("\nShutting down services...\n");
|
printf("\nShutting down services...\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|||||||
Reference in New Issue
Block a user