62 Commits

Author SHA1 Message Date
Rainer Gerhards
b326c76f45 style: normalize C source formatting via clang-format (PoC)
This commit applies the new canonical formatting style using `clang-format` with custom settings (notably 4-space indentation), as part of our shift toward automated formatting normalization.

⚠️ No functional changes are included — only whitespace and layout modifications as produced by `clang-format`.

This change is part of the formatting modernization strategy discussed in:
https://github.com/rsyslog/rsyslog/issues/5747

Key context:
- Formatting is now treated as a disposable view, normalized via tooling.
- The `.clang-format` file defines the canonical style.
- A fixup script (`devtools/format-code.sh`) handles remaining edge cases.
- Formatting commits are added to `.git-blame-ignore-revs` to reduce noise.
- Developers remain free to format code however they prefer locally.
2025-07-16 13:56:21 +02:00
Rainer Gerhards
08501b930f
CI: add check for compile with -std=gnu23 gcc option
Note: The upcoming gnu23 C standard is overdoing it with type-safety. Inside
rsyslog, we historically have method tables for generic calls, which
keeps the code small and easy to understand. This would not decently be
possible with the new type-safety requirements.

So this commit works around these warning in a way that pretends to
provide more type safety. We have done this in the least intrusive
way to reduce the risk for regressions in code that works well in
since decades. Also note that the code already does parameter
validation.

There would have been more elaborate ways to make gnu23 compile happy,
e.g. by using a union of structs to provide the data element. Some folks
consider this type safe. In reality, it is not a bit better than
traditional C without types at all. Because the caller still needs to
ensure it picks the right struct from the union. As this approach
would also have larger regeression potential, we have not used it.

Right now, we have suppressed some of the new warnings, as working
around them would have required an even larger time budget and
potentially larger regression potential. In the long term we may
want to look into enabling them, as they would potentially be
beneficial for new code not involving method tables.

Some nits, however, were detected and have been fixed.

This patch also "fixes" some false positive test failures, mostly
be disabling some test functionality after confirmation these are
flakes.

see also https://github.com/rsyslog/rsyslog/issues/5507
2024-12-31 10:29:00 +01:00
MIZUTA Takeshi
0b830970c2 Don't refer to errno when the pthread library fails
When the pthread library fails, errno is referenced even though errno is not set.
Fix to refer to the return code of the pthread library instead of errno.
2022-03-03 10:34:54 +09:00
alakatos
321fc76f0f Move rsyslog global parameters to rsconf_t struct 2022-01-13 12:43:21 +01:00
Rainer Gerhards
29500f75f4
core/tcpsrv: potential race on startup/shutdown
if the tcpsrv component is started and quickly terminated, it may hang
for a short period of time. Also a very small amout of memory is leaked
immediately before shutdown. While this leak is irrelevant in practice
(the OS clean up the process anyways), it leads to CI failures. The hang,
however, can lead to longer than expected shutdown times for rsyslog.

The problem can be experienced via imtcp, imgssapi and imdiag (users
of affected core component).
2019-08-19 09:05:47 +02:00
Rainer Gerhards
9bece39dc6
SQUASH
debug cleanup: remove some old, no longer used macros
2018-10-30 12:46:04 +01:00
PascalWithopf
c83e3ed216 correct codestyle in rsyslog part 2 2018-08-01 16:11:33 +02:00
Rainer Gerhards
5c90771758 core bugfix: input shutdown timeout not properly applied
The timeout could be reduced by mutex wait time, which was not the
intended behaviour and could lead the the input thread being
cancelled while it would have been perfectly legal to shut it down
cleanly.

Noticed during working on the CI system. May explain some testbench
instability and may have caused trouble with state files (not)
properly being written by inputs.
2018-07-27 09:09:38 +02:00
Rainer Gerhards
e200b2192f add new global config parameter "inputs.timeout.shutdown" 2018-07-27 09:09:38 +02:00
Rainer Gerhards
aa4cd2a4da test instrumentation: emit message when thread is cancelled
This is purely for debugging, and aimed at helping find some race
within the testbench. We know it happens, but it is unfortunately
totally unreproducible, so we try to gather data as less invasive
as possible.
2018-07-27 09:09:38 +02:00
Rainer Gerhards
2254fe214e core: fix potential race
This fixes a potential race that valgrind's helgrind found on some
very few occasions, and right now only on CentOS 7. However, it
looks like the variable was actually not correctly protected.

see also https://github.com/rsyslog/rsyslog/issues/2012
2017-12-16 14:24:12 +01:00
Rainer Gerhards
10825c470a core: enable SEGV handler to aid in getting core dumps
also simplified thread-specific signal setup
2017-11-08 11:27:19 +01:00
Rainer Gerhards
7c273a3314 core: emit error message on abnormal input thread termination
this in almost all cases indicates a real problem that the user
should be made aware of

For a case where the missing error message caused confusion
see also https://github.com/rsyslog/rsyslog/issues/1867
2017-10-20 09:22:45 +02:00
Pascal Withopf
b63a6b9010 codestyle: line length adjusted 2017-01-17 08:54:37 +01:00
purnima
d45daa2af0 Rebase,redefine msgDestruct() as smsg_t is used 2016-11-22 14:24:25 +05:30
Rainer Gerhards
bbcbb03c64 fix compiler warnings 2016-07-22 15:00:28 +02:00
Rainer Gerhards
b3940cb966 remove excessive "inline" attributes 2016-06-03 12:24:27 +02:00
Rainer Gerhards
8e4bfe19b5 core: set default stack size to 4MiB
Note that this is below the usual 10MiB default, but should cause
no issues (output threads already use 4MiB stack size, for example).
This also addresses issues introduced by micro-libc's which only
provide very limited stack space by default.

closes https://github.com/rsyslog/rsyslog/issues/996
2016-04-29 10:10:29 +02:00
Rainer Gerhards
8a10940b5d bugfix: afterRun entry point not correctly called
The entry point was called at the wrong spot, only when the thread
had not already terminated by itself. This could cause various
cleanup to not be done.

closes https://github.com/rsyslog/rsyslog/issues/882
2016-04-23 18:15:49 +02:00
Peter Portante
cc9b7ced03 EXPERIMENT: join always, except already exited, proper predicate loop 2016-02-28 23:00:48 -05:00
Michael Biebl
3e8ab2d389 fix build on non-Linux systems 2013-03-22 09:39:00 +01:00
Rainer Gerhards
17d48fc499 added capability to output thread-id-to-function debug info
This is a useful debug aid, but nothing of concern for regular users.
2013-01-13 12:14:58 +01:00
Rainer Gerhards
8939ccfffd Merge branch 'v5-stable' into v6-stable
Conflicts:
	ChangeLog
	action.c
	configure.ac
	doc/manual.html
	runtime/ruleset.c
	template.h
	threads.c
	tools/syslogd.c
2012-08-25 11:55:41 +02:00
Rainer Gerhards
9faf2240c4 changed TRUE/FALSE to RSTRUE/RSFALSE
This is done to prevent name claches with libraries.
2012-08-22 15:29:02 +02:00
Rainer Gerhards
1d7ba92156 better debug instrumentation --> input thread names used for reporting 2012-05-02 16:01:13 +02:00
Rainer Gerhards
0871d0a077 Merge branch 'v4-stable' into v5-stable
Conflicts:
	plugins/imfile/imfile.c
	plugins/omtesting/omtesting.c
	tcpsrv.c
	threads.c
2012-01-14 18:32:40 +01:00
Rainer Gerhards
0216053099 relicense parts under ASL 2.0
after carful check for copyright holder
2012-01-11 18:30:33 +01:00
Rainer Gerhards
39406781e5 bugfix: minor race condition in action.c - considered cosmetic
This is considered cosmetic as multiple threads tried to write exactly
the same value into the same memory location without sync. The method
has been changed so this can no longer happen.
2011-02-17 15:12:54 +01:00
Rainer Gerhards
f3d354da3e bugfix: very long running actions could prevent shutdown under some circumstances
This has now been solved, at least for common situations.
2011-02-11 17:47:30 +01:00
Rainer Gerhards
f7c2092004 Merge branch 'v5.6.2-newimudp' into v5-devel-newimudp
Conflicts:
	plugins/imudp/imudp.c
	threads.c
2011-01-10 12:54:21 +01:00
Dražen Kačar
7742b2182f improved imudp real-time scheduling support & bugfix
The original code had quite some issues, which are fixed by this
commit. Also we do more error checking now.

Signed-off-by: Rainer Gerhards <rgerhards@adiscon.com>
2011-01-10 12:39:23 +01:00
Rainer Gerhards
189a26c044 Merge branch 'v4-stable' into v5-stable
Conflicts:
	ChangeLog
	runtime/parser.c
	runtime/queue.c
	runtime/wtp.c
	template.c
	threads.c
	tools/syslogd.c
2010-12-16 13:59:16 +01:00
Rainer Gerhards
371a8eec29 some cleanup based on clang static analyzer results 2010-12-16 12:57:55 +01:00
Rainer Gerhards
38cb392672 replaced data type "bool" by "sbool" because this created some portability issues 2010-02-02 15:51:01 +01:00
Rainer Gerhards
e005c5569c some minor cleanup, consolidated some code 2009-10-16 09:42:36 +02:00
Rainer Gerhards
e53d91ce66 solved a recently introduced race during input thread shutdown
This was introduced when we re-enabled non-cancel thread termination
a few commits ago. This code has never been released as a tarball,
so that is no bugfix for a release but rather a WiP regression fix
and thus does not need to be mentioned in the ChangeLog.
2009-10-15 18:33:33 +02:00
Rainer Gerhards
08fca4477c re-enabled input thread termination handling that does avoid thread cancellation
...where possible. This provides a more reliable mode of
rsyslogd termination (canceling threads my result in not properly
freed resouces and potential later hangs, even though we perform
proper cancel handling in our code). This is part of an effort to
reduce thread cnacellation as much as possible in rsyslog.

NOTE: some comments indicated that there were problems with some code
that has been re-activated. Testing did not show any issues. My current
assumption is that these issues were related to some other code that
has been removed/changed during the previous restructuring events.
In any case, if there is a shutdown issue, one should carefully look
at this change here!
2009-10-12 17:10:04 +02:00
Rainer Gerhards
a5e8684b91 disabling new input termination interface
a bug showed up during further testing. As this was a side-activity,
I'll probably disable it for the time being and check what's going on
somewhat later (I'll do it tomorrow if I can find it quickly)
2009-07-20 19:01:03 +02:00
Rainer Gerhards
7d92de155c internal: added ability to terminate input modules not via pthread_cancel...
... but an alternate approach via pthread_kill. This is somewhat safer as we
do not need to think about the cancel-safeness of all libraries we use.
However, not all inputs can easily supported, so this now is a feature
that can be requested by the input module (the most important ones
request it).
2009-07-20 18:36:30 +02:00
Rainer Gerhards
7b63cd6fed minor things, mostly improved debug info 2008-09-18 12:44:00 +02:00
Rainer Gerhards
8a1751d1c9 Merge branch 'v3-stable' into beta
Conflicts:

	ChangeLog
	configure.ac
	doc/rsyslog_ng_comparison.html
2008-08-15 12:59:24 +02:00
Rainer Gerhards
7b456ce548 bugfix: imfile could cause a segfault upon rsyslogd HUP and termination
Thanks to lperr for an excellent bug report that helped detect this
problem.
2008-08-14 11:19:02 +02:00
Rainer Gerhards
d9b0c77d3e some more cleanup
reduced dependencies, moved non-runtime files to its own directory except
for some whom's status is unclear
2008-04-16 15:27:53 +02:00
Rainer Gerhards
52ac1ab34c worked some more on HP UX - got it to compile and receive UDP messages 2008-03-06 11:20:36 +00:00
Rainer Gerhards
a914e3164e - removed no longer necessary signal from threads.c
- changed debug output request signal to SIGUSR2 (as originally intented),
    restored SIGUSR1 semantics
2008-02-18 10:41:07 +00:00
Rainer Gerhards
5c686c8adc redesigned queue to utilize helper classes for threading support. This is
finally in a running state for regular (non disk-assisted) queues, with
    a minor nit at shutdown. So I can finally commit the work again to
    CVS...
2008-01-24 17:55:09 +00:00
Rainer Gerhards
68efb41220 - some cleanup
- implemented management function for worker thread 0 in order to change
    queue workers dynamically -- stage work
2008-01-10 17:33:21 +00:00
Rainer Gerhards
28c44e9a7b - fixed a bug that caused a segfault on startup when no $WorkDir directive
was specified in rsyslog.conf
- fixed a bug that caused a segfault on queues with types other than "disk"
- removed the now longer needed thread TermSyncTool
2008-01-10 14:27:26 +00:00
Rainer Gerhards
29d9729292 moved queue code to its own module (finally) 2008-01-03 09:44:54 +00:00
Rainer Gerhards
cebbf6d44e some cleanup 2007-12-27 14:29:09 +00:00