This ensures multithreaded logging attempts, in particular ones that do
nothing, do not hold the lock just for checking the level, which
interferes with other logging attempts.
Closes: OS#5818
Change-Id: I35f8dd9127dd6e7feae392094fd6b3ce2d32558d
In the _output_buf() we explicitly initialize only the 'buf' and 'len'
fields of the struct osmo_strbuf, leaving the 'pos' field implicitly
initialized to NULL. Later, in this function, 'sb.pos' is passed to
ctime_r() and strlen(), leading to a NULL pointer dereference (segfault)
in certain scenarios.
This situation can occur when color logging is disabled or when
a specific logging subsystem has no associated color. Any application
using libosmocore's logging API would crash with the following config:
log stderr
logging filter all 1
logging timestamp 1
logging color 0
Fix this by initializing the 'pos' field explicitly.
Change-Id: I7ec9badf525e03e54e10b725d820c636eaa3fd1c
Fixes: d71331bc "logging: fix nul octets in log output / use osmo_strbuf"
Fixes: CID#336550
Patch [1] merged few weeks ago, for yet unknown reasons, sprinkles nul
characters at seemingly randomly chosen log line ends.
Trying to figure out why that happens, i got tired of the unreadable
cruft, and decided to migrate the _output_buf() implementation to
osmo_strbuf first.
With osmo_strbuf in use and implementing 1:1 what the previous code did,
the odd nul octets have disappeared. So the bug was caused by unreadable
code.
[1] 11a416827d
Ia7de9d88aa5ac48ec0d5c1a931a89d21c02c5433
"logging: ensure ANSI color escape is sent in same line/before newline"
Related: OS#6284
Related: Ia7de9d88aa5ac48ec0d5c1a931a89d21c02c5433
Change-Id: Ib577a5e0d7450ce93ff21f37ba3262704cbf4752
This fixes multi-line color clobbering in logging daemons like
systemd-journald, which work with single-lines only.
Change-Id: Ia7de9d88aa5ac48ec0d5c1a931a89d21c02c5433
Closes: OS#6249
* make backend configurable for later
* segmentation callback for chunked streams
* logging target for osmo_io
* support partial writes
Change-Id: I50d73cf550d6ce8154bf827bf47408131cf5b0a0
Related: SYS#5094, OS#5751
It makes no sense to call osmo_fd_unregister() on a negative fd.
Let's also make sure we set fd to negative value after unregistering +
closing, even if the struct is going to be freed afterwards.
Change-Id: I0790a63e603028c11cc475d483c6528e4d9aa9ab
config.h is created in $(top_buildir)/config.h.
Let's make sure all CPPFLAGS add correct -Ipath includes,
and that all code includes the correct file.
Change-Id: Ie9ea38bb009bc715b01cde4d66d181f7bec2e7bd
This way we have all libosmocore.so in an own subdir instead of having
lots of files in the parent dir, which also contains subdirs to other
libraries.
This also matches the schema under include/osmocom/.
Change-Id: I6c76fafebdd5e961aed88bbecd2c16bc69d580e2