When we log internal messages to syslog (the default starting with 8.21),
early error messages can result in rsyslogd hanging, as well as everything
else that wants to log hanging.
This is the result of deadlock: rsyslog tries to write to the log socket,
which blocks but can't be unblocked as rsyslog processing would need to
advance to do so. Interestingly, this only happens occasionally (even
though the startup sequence is deterministic at this point), so it is
hard to diagnose. Also, not all platforms seem to be affected. Platforms
with systemd journal will never run into a deadlock (as journal in this
case reads the system log socket).
The root cause is that for internal messages we maintain a queue for
such early messages and emit them only after full startup. Similar code
is missing when writing to the log socket. The full code has been
restructured so that this condition is obeyed under all conditions.
closes https://github.com/rsyslog/rsyslog/issues/1188
As it seems, different C compilers have different rules/interpretations
on inline functions. The current code base did not properly obey all C99
rules. We fix this by converting some functions to macros and others to
include the necessary C99 plumbing. We also remove some inline attributes
for functions where this seems to be to agressive (aka "function to big").
This fixes build problems in some environments and is a general code
cleanup measure.
json-c objects cannot be used on multiple threads and so we
need to guard against this. Note that this was already handled
in many cases by totally locking the message, what we now do
no longer. So all in all, it could even improve performance for
configs where json is used. For others, it slightly decreases,
because we need to initialize the rwlocks for each message.
MsgSetRawMsg() always enforces termination by a zero
byte. MsgSetRawMsgSize() is used in SanitizeMsg() in a way that
suggests zero-temination. Amend MsgSetRawMsgSize() to be consistent
with the semantics of MsgSetRawMsg().
- add message metadata "system" to msg object
this permits to store metadata alongside the message
- imfile: add support for "filename" metadata
this is useful in cases where wildcards are used
see also https://github.com/rsyslog/rsyslog/issues/199
I originally thought that I would need to do dynamic memory
alloc and extended the interface to support this. Fortunatley,
this could be avoided, and so I undo that change now.
The primary reason is to avoid unnecessary merge conflicts
when merging up to newer code, which more insist on the
"const correctness" - but we may get some optimizer benefits
as well.
This also lead to a slight performance optimization in the msg.c
module (when it comes to querying structured data).
This is stage work in order to provide the capability to fully
parse structured data.