kore

An easy to use, scalable and secure web application framework for writing web APIs in C.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 93ec99c23ef96103776746898c55f4c644ee4643
parent 93a4fe2a15738d2ecd2f97b219b3ac698bb348e4
Author: Joris Vink <joris@coders.se>
Date:   Fri, 28 Jan 2022 14:29:58 +0100

Only enable accesslog vacuum if needed.

If no accesslogs are enabled, the parent has no need for
the vacuum timer to be activated.

This way the parent blocks in epoll_wait() instead of waking up
for no reason when there are no accesslogs enabled.

Diffstat:
src/kore.c | 19++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/kore.c b/src/kore.c @@ -857,6 +857,10 @@ kore_server_start(int argc, char *argv[]) struct kore_server *srv; u_int64_t netwait; int last_sig; +#if !defined(KORE_NO_HTTP) + int alog; + struct kore_domain *dom; +#endif #if defined(KORE_SINGLE_BINARY) struct kore_runtime_call *rcall; #endif @@ -952,8 +956,21 @@ kore_server_start(int argc, char *argv[]) worker_max_connections = tmp; kore_timer_init(); + #if !defined(KORE_NO_HTTP) - kore_timer_add(kore_accesslog_run, 100, NULL, 0); + alog = 0; + + LIST_FOREACH(srv, &kore_servers, list) { + TAILQ_FOREACH(dom, &srv->domains, list) { + if (dom->accesslog != -1) + alog = 1; + } + } + + if (alog) { + kore_timer_add(kore_accesslog_run, 100, NULL, 0); + kore_log(LOG_INFO, "accesslog vacuum is enabled"); + } #endif #if defined(KORE_USE_PYTHON)