diff --git a/src/main.c b/src/main.c index 84c6c77..c9e2167 100644 --- a/src/main.c +++ b/src/main.c @@ -195,7 +195,7 @@ int main(int argc, char** argv) { } if (report_queued > 0) { report_queued = 0; - report(); + report(1); } if (last_doc_generated <= now - web_refresh) { index_doc = generate_index(); diff --git a/src/services.c b/src/services.c index 2f250e6..c990abf 100644 --- a/src/services.c +++ b/src/services.c @@ -268,7 +268,7 @@ uint8_t add_endpoint(struct Service* self, const char* uri) { return 0; } -void report() { +void report(int min_gap) { if (status_timeline.size + 1 >= status_timeline.capacity) vector_pop_front(&status_timeline); // remove (what should be) oldest entry @@ -284,6 +284,7 @@ void report() { vector_push_back(&peroid->server_statuses, &server_status); } + if (status_timeline.size > 0 && (*((struct StatusPeroid**)vector_back(&status_timeline)))->time >= queued_time - (min_gap * 1000000)) return; vector_push_back(&status_timeline, &peroid); } diff --git a/src/services.h b/src/services.h index dc1d086..cbb32dc 100644 --- a/src/services.h +++ b/src/services.h @@ -23,12 +23,12 @@ struct EndpointStatus; struct Endpoint; struct Service; -void report(); void* run_endpoint(void* endpoint); void queue_report(struct EndpointStatus status); void load_service(struct Service** self); uint8_t add_endpoint(struct Service* self, const char* uri); enum State get_state(struct Service** self); +void report(int min_gap); struct ServerStatus* update_server_status(struct Service** self); void deinit_service(struct Service** self); const char* state_text(enum State state);