From 1fcf99817580379d3e7550d1d874050a3e0315bc Mon Sep 17 00:00:00 2001 From: Xenofon Karamanos Date: Fri, 2 Feb 2024 13:16:08 +0000 Subject: [PATCH] file_out: make worker sleep period configurable, to allow to adapt performance parameters --- src/modules/file_out/doc/file_out_admin.xml | 19 +++++++++++++++++++ src/modules/file_out/file_out.c | 8 +++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/modules/file_out/doc/file_out_admin.xml b/src/modules/file_out/doc/file_out_admin.xml index 3054af61672..bcb3f5d14e9 100644 --- a/src/modules/file_out/doc/file_out_admin.xml +++ b/src/modules/file_out/doc/file_out_admin.xml @@ -135,6 +135,25 @@ modparam("file_out", "extension", ".txt") ... modparam("file_out", "interval_seconds", "300") +... + + + + + <varname>worker_usleep</varname> (int) + + The time in microseconds which worker will sleep for until next iteration. + + + + Default value is 10000 (10 ms). + + + + Set <varname>worker_usleep</varname> parameter + +... +modparam("file_out", "worker_usleep", "1000") ... diff --git a/src/modules/file_out/file_out.c b/src/modules/file_out/file_out.c index 1b9bfba7bb0..dada154eb12 100644 --- a/src/modules/file_out/file_out.c +++ b/src/modules/file_out/file_out.c @@ -61,6 +61,7 @@ char *fo_base_folder = "/var/log/kamailio/file_out/"; char *fo_base_filename[FO_MAX_FILES] = {""}; char *fo_extension = ".out"; int fo_interval_seconds = 10 * 60; +int fo_worker_usleep = 10000; /* Shared variables */ fo_queue_t *fo_queue = NULL; @@ -78,7 +79,8 @@ static param_export_t params[] = { {"base_folder", PARAM_STRING, &fo_base_folder}, {"base_filename", PARAM_STRING | PARAM_USE_FUNC, &fo_add_filename}, {"interval_seconds", PARAM_INT, &fo_interval_seconds}, - {"extension", PARAM_STRING, &fo_extension}, {0, 0, 0}}; + {"extension", PARAM_STRING, &fo_extension}, + {"worker_usleep", PARAM_INT, &fo_worker_usleep}, {0, 0, 0}}; struct module_exports exports = { "file_out", /* module name */ @@ -139,7 +141,7 @@ static int child_init(int rank) return 0; } - pid = fork_process(PROC_NOCHLDINIT, "log_writ", 1); + pid = fork_process(PROC_NOCHLDINIT, "fo_writer", 1); if(pid < 0) { LM_ERR("fork failed\n"); return -1; /* error */ @@ -159,7 +161,7 @@ static int child_init(int rank) /* update the local config framework structures */ cfg_update(); - usleep(10000); + usleep(fo_worker_usleep); fo_log_writer_process(rank); } // return 0;