diff options
author | Harald Welte <laforge@osmocom.org> | 2020-09-26 21:45:16 +0200 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2021-10-26 17:16:47 +0200 |
commit | b72867f0e68c96ca25e1f9929ce92be0a802db6b (patch) | |
tree | 2f1200f645ee47d49bf39ebdf802a82fb10d9d5a /tests/logging | |
parent | 8db64ee81019d046fc61c61db77dacfadfe5165b (diff) |
logging: Change stderr + file target to use non-blocking write
So far, we used blocking, buffered fwrite() to write to stderr
and file targets. This causes problems if there are [slow] consumers
causing delays, such as gnome-terminal (when the program is started
interactively) or systemd/journald (where we observe 64..128ms blocks on
stderr).
This patch introduces stderr/file based logging via write_queue
and osmo_select_main(), i.e. switch from glibc-buffered, blocking
to internally buffered, non-blocking writes.
* when osmo_stderr_target is created via application.c, we create it
in blocking stream mode for backwards compatibility, particularly
for [smaller] programs that don't use osmo_select_main()
* when the VTY code encounters 'log stderr' or 'log file FILENAME',
we switch that respective target to non-blocking write-queue mode,
as this means the application is in fact using osmo_select_main()
* The config file can now state 'log stderr blocking-io' or
'log file FILENAME blocking-io' to explicitly enforce using blocking
stream based I/O
* The application can at any time use API functions to switch either way
Closes: OS#4311
Change-Id: Ia58fd78535c41b3da3aeb7733aadc785ace610da
Diffstat (limited to 'tests/logging')
-rw-r--r-- | tests/logging/logging_vty_test.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/tests/logging/logging_vty_test.c b/tests/logging/logging_vty_test.c index e7019f61..078555e9 100644 --- a/tests/logging/logging_vty_test.c +++ b/tests/logging/logging_vty_test.c @@ -254,6 +254,7 @@ int main(int argc, char **argv) log_set_print_category_hex(osmo_stderr_target, 0); log_set_print_level(osmo_stderr_target, 1); log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE); + log_target_file_switch_to_wqueue(osmo_stderr_target); if (cmdline_config.config_file) { rc = vty_read_config_file(cmdline_config.config_file, NULL); |