309 Commits

Author SHA1 Message Date
Rainer Gerhards
2640eb6211 queue subsystem: fix NULL pointer dereference during config processing
If the queue parameters were incorrectly given, a NULL pointer derefernce
could happen during config parsing. Once post that stage, no problem could
occur.

Detected by Coverity scan, CID 185339
2017-11-17 19:17:16 +01:00
PascalWithopf
e485c5c5bc codestyle: shorten lines to max 130 chars 2017-11-15 09:04:42 +01:00
Rainer Gerhards
520264a500 core/queue: fix potential race during shutdown
more or less cosmetic, but pollutes thread debuggers
2017-11-10 08:59:41 +01:00
Rainer Gerhards
6d89c9cdbe imdiag: fix cosmetic race in termination processing
This is not a real problem because imdiag intentionally does multiple
tries to validate predicate validity. However, this is reported in
clang thread sanitizer and so we need to fix it.
2017-11-05 15:57:38 +01:00
Jan Gerhards
e03133362c queue: enhance error message
closes https://github.com/rsyslog/rsyslog/issues/1876
2017-10-21 16:17:28 +02:00
Rainer Gerhards
3fbd901b3e core bugfix: potential segfault when shutting down rsyslog
when rulesets are nested a segfault can occur when shutting down
rsyslog. the reason is that rule sets are destructed in load order,
which means a "later" ruleset may still be active when an "earlier"
one was already destructed. In these cases, a "call" can invalidly
call into the earlier ruleset, which is destructed and so leads to
invalid memory access. If a segfault actually happens depends on the
OS, but it is highly probable.

The cure is to split the queue shutdown sequence. In a first step,
all worker threads are terminated and the queue set to enqOnly.
While some are terminated, it is still possible that the others
enqueue messages into the queue (which are then just placed into the
queue, not processed). After this happens, a call can no longer
be issued (as there are no more workers). So then we can destruct
the rulesets in any order.

closes https://github.com/rsyslog/rsyslog/issues/1122
2017-10-18 11:00:24 +02:00
Rainer Gerhards
44f035a263 core: improve object type assertion macro
now invalid object type is explicitely given in error
message
2017-06-27 08:07:15 +02:00
Rainer Gerhards
d741c3e218 queue subsystem: switch to new errmsg obj interface
This is just an internal change meant to be slightly more
efficient.
2017-03-20 15:44:57 +01:00
Rainer Gerhards
1eae620418 improve queue error messages
with the recent change that permits us to emit error messages at
(alomost) any time, we can now provide better end-user diagnostics.
This patch generates error message which could previously only be
logged to the debug log.
2017-03-20 15:44:57 +01:00
Rainer Gerhards
b8e5e9bb82 core: add additional debug output
This is useful for tracking queue corruption. Was added as part
of tracking down github issue #1404.

As an unrelated small change, we slightly improve the debug
information imuxsock emits.

see also https://github.com/rsyslog/rsyslog/issues/1404
2017-02-08 18:31:18 +01:00
purnima
d45daa2af0 Rebase,redefine msgDestruct() as smsg_t is used 2016-11-22 14:24:25 +05:30
Rainer Gerhards
cc6e579849 Merge pull request #1142 from zinix-workshop/sampling-logs-by-line-in-queue
Add configuration item `queue.samplinginterval` for queue
2016-11-03 12:05:23 +01:00
Rainer Gerhards
fec4f05c41 core: fix missing header file
lead to a debug output not being properly on all platforms
2016-10-10 18:15:25 +02:00
zacharyzhao
9c84ccba18 Add configuration item queue.samplinginterval for queue 2016-10-10 17:29:16 +02:00
Rainer Gerhards
c403a56f09 remove inline from excessively long functions 2016-10-08 16:50:12 +02:00
Rainer Gerhards
a86806a249 "solve" clang static analyzer report
This is a false positive, but we need to work around it.
2016-08-22 17:14:23 +02:00
Rainer Gerhards
08f8b1b1a6 queue subsystem: do not leave empty file on disk on shutdown
the queue subsystem left an empty file on disk if this was an
output file just created but not yet data written to it. This
is now fixed.
2016-08-22 16:20:02 +02:00
Rainer Gerhards
08dc0a1807 queue subsystem: remove force-persist at begin of shutdown sequence
first of all, this creates race issues and as such is not clean. We
also do no longer need it, as the changes we made to file rollover
cover this use case as well. So instead if working on proper sync,
which is complex, we remove this operation again. Note that it
was NOT present in any released version, just the has been inside
the code the past couple of days while we work on queue robustness.
2016-08-22 16:20:02 +02:00
Rainer Gerhards
24bab3b108 queue subsystem: .qi file is automically rewritten
previously, a kill -9 during the .qi write could keep the file
in inconsistent state. Now, we first write a temp file, and
(automically) rename it to "the real thing". So if something happens
during writing the .qi, at least the old state still is consistent.

This is inspired by the way the pid file is handled sind v8.19.
2016-08-22 16:20:02 +02:00
Rainer Gerhards
1d21860835 queue subsystem: further improve robustness
This now also guards the first write to the new file after
queue rollover. That permits rsyslog to clean out the file
after restart.

Also, a robustness write is now done when a queue file is
fully processed and deleted. Otherwise, the .qi file contains
a non-longer-existing read file number.
2016-08-22 16:20:02 +02:00
Rainer Gerhards
d078f40481 nit: code style fix (cosmetic) 2016-08-22 16:20:02 +02:00
Rainer Gerhards
84ab69fdfd queue subsystem: increase robustness against unexcpected rsyslog termination
The most probable error case are a) power off b) forceful termination during
regular system shutdown. This patch writes the .qi file out whenever a new
queue file is begun. This prevents the loss of more than a single queue data
file in abort conditions.
2016-08-22 16:20:02 +02:00
Rainer Gerhards
f614284722 queue subsystem: harden disk queue against being killed at shutdown
At least a consistent .qi file is written at the being of the shutdown
processing.
2016-08-22 16:20:02 +02:00
Rainer Gerhards
b3940cb966 remove excessive "inline" attributes 2016-06-03 12:24:27 +02:00
Rainer Gerhards
8a8675b223 fix compiler warnings 2016-06-02 10:18:05 +02:00
Rainer Gerhards
ee6b11f9ad cleanup: remove unused code 2016-04-25 08:09:18 +02:00
Rainer Gerhards
4157c956cd queue subsystem: recover from .qi file that states too-large queue size
closes https://github.com/rsyslog/rsyslog/issues/921
closes https://github.com/rsyslog/rsyslog/issues/868
2016-03-30 14:14:23 +02:00
Peter Portante
2470f0f72b Remove use of sizeof(char) and sizeof(uchar)
Remove the use sizeof(char) or sizeof(uchar) in calculations for memory
allocation or string length.  There are no known platforms for which
sizeof(char) or sizeof(uchar) is not 1, and c99 has defined sizeof(char)
to be 1 (section 6.5.3.4 of c99).
2015-12-16 02:18:45 +00:00
525affa670 diskqueue: Fixed two minor issues when syncqueuefiles is enabled.
First issue: Error 14 was generated on the .qi file directory handle.
As the .qi filestream does not have a directory set, fsync
was called on an empty directory causing a error 14 in debug log.
closes https://github.com/rsyslog/rsyslog/issues/402

Second issue: When queue files existed on startup, the bSyncQueueFiles
strm property was not set to 1. This is now done in the
qqueueLoadPersStrmInfoFixup function.
closes https://github.com/rsyslog/rsyslog/issues/403
2015-08-05 11:08:59 -07:00
Rainer Gerhards
b59d11bc93 silence static analyzer warning and potential follow-up error
This "fixes" a false positive from clang static analyzer, which
cannot detect with the previous code that the queue type cannot
change during function calls. Well, actually a memory corruption
*could* trigger using an inconsistent queue type (but so can
corruption of the new variable, albeit even far less likely).
2015-06-26 10:53:27 +02:00
Rainer Gerhards
14643a51de bugfix: queue subsystem emits warning messages with "error" severity 2015-02-24 13:07:17 +01:00
Rainer Gerhards
423c3ac62c pstats: add "origin" paramter to stats records
see also: https://github.com/rsyslog/rsyslog/issues/119
2014-11-19 15:49:09 +01:00
Rainer Gerhards
e563446c61 Merge branch 'v7-stable' into v8-stable 2014-10-24 12:20:17 +02:00
Bojan Smojver
e4bc1b5448 bugfix: typo in queue configuration parameter name 2014-10-24 12:18:13 +02:00
Rainer Gerhards
4b1964712c Merge branch 'v7-stable' into v8-stable
Conflicts:
	runtime/ruleset.c
2014-07-22 22:52:29 +02:00
Rainer Gerhards
0152b9f221 fix regression from commit a955a9900629e2065e3ed1dd9d8f5a94e6faa7f0 2014-07-22 22:11:34 +02:00
Rainer Gerhards
979d36a08b Merge branch 'v7-stable' into v8-stable 2014-07-22 17:48:30 +02:00
Tomas Heinrich
a955a99006 bugfix: check return value of malloc()
Error: NULL_RETURNS (CWE-476):
rsyslog-7.4.10/runtime/queue.c:2126: returned_null: Function "malloc(size_t)" returns null (checked 140 out of 168 times).
rsyslog-7.4.10/action.c:1197: example_checked: Example 1: "malloc(batchNumMsgs(pBatch) * 1UL)" has its value checked in "(active = malloc(batchNumMsgs(pBatch) * 1UL)) == NULL".
rsyslog-7.4.10/grammar/lexer.l:302: example_checked: Example 2: "malloc(40UL)" has its value checked in "(bs = malloc(40UL)) == NULL".
rsyslog-7.4.10/grammar/rainerscript.c:2483: example_checked: Example 3: "malloc(8UL)" has its value checked in "(ar->arr = malloc(8UL)) == NULL".
rsyslog-7.4.10/plugins/imklog/bsd.c:221: example_checked: Example 4: "malloc(1UL * (iMaxLine + 1))" has its value checked in "(pRcv = (uchar *)malloc(1UL * (iMaxLine + 1))) == NULL".
rsyslog-7.4.10/plugins/imuxsock/imuxsock.c:968: example_checked: Example 5: "malloc(1UL * (iMaxLine + 1))" has its value checked in "(pRcv = (uchar *)malloc(1UL * (iMaxLine + 1))) == NULL".
rsyslog-7.4.10/runtime/queue.c:2126: var_assigned: Assigning: "pThis->mut" = null return value from "malloc(size_t)".
rsyslog-7.4.10/runtime/queue.c:2127: dereference: Dereferencing a pointer that might be null "pThis->mut" when calling "pthread_mutex_init(pthread_mutex_t *, pthread_mutexattr_t const *)".
2014-07-22 17:45:49 +02:00
Rainer Gerhards
a45ea8a144 testbench: make more reliable shutdown
so far, we checked only the main queue size to become zero, ignoring
the sizes of action queues. For some tests, this caused racieness and
unreliability. Now, we check all queues. This should make matters
much more stable.
2014-07-11 17:23:21 +02:00
Rainer Gerhards
93cf514504 Merge branch 'v7-stable' into v8-stable 2014-05-28 12:13:27 +02:00
Rainer Gerhards
8e81842a4d fix compiler warnings on 64bit platforms 2014-05-28 12:12:31 +02:00
Rainer Gerhards
77d3142c61 Merge branch 'v7-devel' 2013-12-10 09:54:43 +01:00
Rainer Gerhards
dcee4926b5 re-enable legacy $WorkDir for queue spool directory use 2013-12-09 15:40:20 +01:00
Rainer Gerhards
292c4fe1b2 regression fix: read queue spool directory after config file has been processed
note that this does not yet support legacy style $WorkDir
2013-12-09 14:56:53 +01:00
Rainer Gerhards
08ea995494 Merge branch 'v7-devel' 2013-12-05 09:03:45 +01:00
Rainer Gerhards
8aeeda6d80 Merge branch 'v7-stable' into v7-devel 2013-12-05 09:03:34 +01:00
Karol Jurak
f6000c70fb bugfix: limiting queue disk space did not work properly 2013-12-05 08:58:04 +01:00
Rainer Gerhards
83dc432503 Merge branch 'v7-devel' 2013-12-01 12:51:11 +01:00
Rainer Gerhards
0d09f78ba8 emit warning message if queue full delay mark is below high wtr mark 2013-12-01 10:34:14 +01:00
Rainer Gerhards
f03431a834 regression fix: action queues with default settings did not start worker thread 2013-11-25 09:40:53 +01:00