Skip to content

Commit

Permalink
file_out: make worker sleep period configurable, to allow to adapt pe…
Browse files Browse the repository at this point in the history
…rformance parameters
  • Loading branch information
xkaraman authored and henningw committed Feb 2, 2024
1 parent 82593a0 commit 1fcf998
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
19 changes: 19 additions & 0 deletions src/modules/file_out/doc/file_out_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,25 @@ modparam("file_out", "extension", ".txt")
<programlisting format="linespecific">
...
modparam("file_out", "interval_seconds", "300")
...
</programlisting>
</example>

<title>
<varname>worker_usleep</varname> (int)</title>
<para>
The time in microseconds which worker will sleep for until next iteration.
</para>
<para>
<emphasis>
Default value is <quote>10000</quote> (10 ms).
</emphasis>
</para>
<example>
<title>Set <varname>worker_usleep</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("file_out", "worker_usleep", "1000")
...
</programlisting>
</example>
Expand Down
8 changes: 5 additions & 3 deletions src/modules/file_out/file_out.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand Down Expand Up @@ -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 */
Expand All @@ -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;
Expand Down

0 comments on commit 1fcf998

Please sign in to comment.