libosmocore/include/osmocom/core
Harald Welte b72867f0e6 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
2021-10-26 17:16:47 +02:00
..
application.h application: do not document unrelated forward-declarations 2020-10-24 04:08:19 +07:00
backtrace.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
base64.h base64: reformat using Lindent to conform to our coding style 2021-09-21 19:57:56 +00:00
bitXXgen.h.tpl bitXXgen: add osmo_loadXXbe_ext_2() to get right-adjusted values 2020-09-14 11:53:46 +00:00
bitcomp.h Fix/Update copyright notices; Add SPDX annotation 2017-11-13 01:35:12 +09:00
bits.h [doc] bits.c: Better / more Doxygen documentation 2017-10-16 14:19:12 +02:00
bitvec.h bitvec: Add bitvec_tailroom_bits() function 2019-02-05 11:16:44 +01:00
byteswap.h fix issue on big endian architecture 2018-04-09 17:32:11 +00:00
conv.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
counter.h cosmetic: get rid of 3 deprecation warnings 2021-09-30 18:33:43 +00:00
crc16.h [doc] Put CRC-16 and generic CRC code in one Doxygen module 2017-10-16 14:29:26 +02:00
crcXXgen.h.tpl [doc] Put CRC-16 and generic CRC code in one Doxygen module 2017-10-16 14:29:26 +02:00
crcgen.h [doc] Put CRC-16 and generic CRC code in one Doxygen module 2017-10-16 14:29:26 +02:00
defs.h core/defs.h: introduce and use OSMO_DEPRECATED_OUTSIDE 2019-12-11 12:42:05 +00:00
endian.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
exec.h exec: Introduce osmo_system_nowait2() to allow specify a user 2020-04-18 15:06:59 +02:00
fsm.h fsm: Add osmo_fsm_inst_broadcast_children() 2020-12-21 15:45:45 +01:00
gsmtap.h gsmtap: Add definitions for E1/T1 payload (LAPD, TRAU, FR) in GSMTAP 2020-08-20 20:07:03 +00:00
gsmtap_util.h gsmtap_util: SNR can be negative, use a signed integer 2021-01-04 17:49:18 +01:00
hash.h Add hlist and hashtable from Linux kernel 2020-12-05 11:39:42 +01:00
hashtable.h Add hlist and hashtable from Linux kernel 2020-12-05 11:39:42 +01:00
isdnhdlc.h isdnhdlc: Port from kernel to userspace 2018-05-11 21:57:46 +02:00
it_q.h Add inter-thread queue 2021-01-06 00:22:13 +01:00
linuxlist.h linuxlist: add macro to get last element of a list 2021-07-07 16:53:47 +02:00
linuxrbtree.h fix FSF address in sources/headers 2015-11-12 13:46:05 +01:00
log2.h log2.h: Avoid redefining __always_inline 2020-12-06 15:45:52 +01:00
logging.h logging: Change stderr + file target to use non-blocking write 2021-10-26 17:16:47 +02:00
logging_internal.h logging: Move extern declaration of osmo_log_target_list from logging.h to logging_internal.h 2019-09-20 15:21:33 +00:00
loggingrb.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
macaddr.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
mnl.h Integrate libmnl (minimal netlink) library with libosmocore select loop 2020-12-02 21:04:51 +00:00
msgb.h msgb_alloc_headroom: Change size args to be uint16_t 2021-06-13 18:20:09 +00:00
msgfile.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
panic.h osmo_panic(): Annotate as __attribute__ ((noreturn)) 2018-06-29 20:32:57 +02:00
plugin.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
prbs.h Add pseudo-random bit sequence generator to libosmcoore 2017-07-10 23:42:02 +02:00
prim.h [doc] Expand Doxuygen documentation for osmo_prim 2017-10-16 14:52:37 +02:00
process.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
rate_ctr.h stat,rate_ctr: Allow setting group name and use it at report time 2021-06-05 15:46:27 +00:00
select.h osmo_select_shutdown_request(): allow finishing pending writes on SIGTERM 2021-06-18 12:22:44 +00:00
sercomm.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
serial.h serial: Introduce API osmo_serial_speed_t 2020-11-13 22:58:14 +01:00
signal.h signal: Introduce API osmo_signal_talloc_ctx_init 2018-08-16 21:03:32 +02:00
sockaddr_str.h sockaddr_str: add osmo_sockaddr_str_from_str2() which doesn't set the port 2020-09-02 15:22:57 +00:00
socket.h socket: QoS support for all our socket init functions 2021-04-28 13:15:20 +02:00
stat_item.h refactor stat_item: get rid of FIFO and "skipped" error 2021-09-30 18:33:43 +00:00
statistics.h Rename 'statistics.c' to 'counter.c' 2017-10-15 19:51:35 +02:00
stats.h stats: Support regular stats flush 2020-05-09 08:08:53 +00:00
strrb.h doxygen: unify use of \file across the board 2017-06-23 00:18:23 +00:00
talloc.h Declare osmo_ctx_init() in talloc.h 2020-12-28 22:29:01 +01:00
tdef.h fix default_timeout type of osmo_tdef_fsm_inst_state_chg default_timeout 2021-04-28 18:31:31 +00:00
thread.h Introduce osmo_gettid() API 2021-02-17 18:24:17 +01:00
timer.h osmo_timer_pending: Make arg const 2021-04-29 20:14:51 +00:00
timer_compat.h timer: Fix clockid_t undefined on MacOS < 10.12 2018-12-10 11:02:16 +01:00
use_count.h add osmo_use_count_to_str_c() 2020-09-20 09:51:32 +00:00
utils.h utils: introduce osmo_talloc_replace_string_fmt() 2021-10-13 14:03:26 +03:00
write_queue.h write_queue: Add osmo_wqueue_enqueue_quiet() 2020-09-29 16:30:56 +00:00