217 Commits

Author SHA1 Message Date
PascalWithopf
c83e3ed216 correct codestyle in rsyslog part 2 2018-08-01 16:11:33 +02:00
PascalWithopf
19133327cc correct codestyle in rsyslog 2018-07-31 09:44:27 +02:00
Radovan Sroka
7e88634f3d Fixed race in asyncWriter
strmFlushInternal needs to be called with locked mutex
2018-06-26 12:50:02 +02:00
Rainer Gerhards
d5cadd26d4 imfile: refactor state file format
We change it to json and also change the way it is stored and loaded.
This sets base to additional improvements in imfile.

closes https://github.com/rsyslog/rsyslog/issues/2529
2018-03-29 09:15:27 +02:00
Rainer Gerhards
193631eac7 stream/bugfix: memory leak on stream open if filename as already generated
this can happen if imfile reads a state file. On each open, memory for the
file name can be lost.

We detected this while working on imfile refactoring, there is no related
bug report. No specific test has been crafted, as the refactored imfile
tests catch it (as soon as they are merged).
2018-03-18 12:10:36 +01:00
Rainer Gerhards
c55f37ef71 bugfix/imfile: memory leak in readMode 0
Bug is actually in stream object, but currently exposed only via imfile.
Happens when in readMode 0 a partial line is read and no more data is
present in the file during that iteration. One partial message is lost
in this case.

closes https://github.com/rsyslog/rsyslog/issues/2421
2018-03-15 13:23:26 +01:00
Jan Gerhards
3db937f376 stream: use new errmsg interface
see also https://github.com/rsyslog/rsyslog/issues/1684
2018-02-05 16:24:46 +01:00
Rainer Gerhards
6a190552d2 core/cstr: stringbuf.c: cstrGetSzStrNoNULL shall not modify buffer
The currently done buffer modification (add of '\0') is bad, especially when
multiple threads access the same string. It is not really an issue that needs
to be urgently fixed, as always the same data is written. However, among others,
it will pollute the thread debugger and as such prevent more elaborate automatted
tests.

closes https://github.com/rsyslog/rsyslog/issues/1993
2017-12-31 18:30:58 +01:00
PascalWithopf
29c9fb1f9a codestyle: reduce line length to 120
lines are still checked for a length of 125 because
these are just some of the lines
2017-12-21 17:09:32 +01:00
PascalWithopf
79de51e4fc codestyle: reduce max line length to 125 2017-12-20 16:16:57 +01:00
Rainer Gerhards
a3f3d8fc6a core/file stream: do not silently ignore error condition
Detected by Coverity scan, CID 185349
2017-11-17 18:06:01 +01:00
PascalWithopf
e485c5c5bc codestyle: shorten lines to max 130 chars 2017-11-15 09:04:42 +01:00
Rainer Gerhards
dd1026c1dc file writer: improved error message
if a file cannot be opened but would need to be for the crypto provider
to work correctly, an error message is now emitted.

Root issue detected by Coverity scan, CID 185338
2017-11-07 17:35:18 +01:00
Rainer Gerhards
a71913029e file stream handler: ensure multiline read is kept valid
We ensure that the previous line segment is always valid... actually this
was already done with existing code, but Coverity scan did not detect this.
Maybe we now get a control flow issue because we do what already happened
in this case...

CID 185423
2017-11-03 19:01:13 +01:00
Rainer Gerhards
8597d15898
Merge pull request #1931 from rgerhards/coverity-8
another set of Coverity scan patches
2017-10-31 10:33:41 +01:00
Rainer Gerhards
a2101e9d52 core/file stream object bugfix: memory leak
If a multiline read errored out, a line buffer could be leaked.

Detected by Coverity scan, CID 185328
2017-10-30 18:53:21 +01:00
Rainer Gerhards
975ca5fedc core/file stream: fix potential infinite loop
Detected by Coverty scan (albeit as different issue), CID 185328
2017-10-29 19:13:04 +01:00
Rainer Gerhards
7933210f7c cosmetic: ensure strmOpenFile() has opened file when returning RS_RET_OK
this tries to fix a potential false positive in Coverity scan. If this does
not work out, we need to explicitely set it to false positive.

CID 185330
2017-10-28 12:58:04 +02:00
Rainer Gerhards
fffbcc2ddc Merge pull request #1758 from rgerhards/pr-1633
implement fileoffset metadata
2017-09-12 08:54:09 +02:00
Rainer Gerhards
0858209381 imfile: adjust offset metadata to give begin offset of file 2017-09-07 17:08:21 +02:00
Rainer Gerhards
e7ace190aa queue bugfix: file write error message was incorrect
when a queue was restarted from disk file, it almost always
emitted a message claiming
"file opened for non-append write, but already contains xxx bytes"
This message was wrong and did not indicate a real error condition.
The predicate check was incorrect.
2017-09-07 08:45:57 +02:00
PascalWithopf
2f40554acb codestyle: correct too long lines 2017-06-29 09:28:21 +02:00
Rainer Gerhards
82bfcf8453 imfile: multiline timeout does not work after rsyslog restart
The timeout feature for multiline reads does not correctly work
for files for which a state file existed. This is usually the
case for files that had been processed by a previous run and
that still exist on the new start. For all other files,
especially those monitored by a wildcard and newly created after
the rsyslog start, timeout worked as expected.

closes https://github.com/rsyslog/rsyslog/issues/1445
2017-06-01 10:12:33 +02:00
PascalWithopf
8ceaddde35 imfile: add posibility to truncate msg
closes https://github.com/rsyslog/rsyslog/issues/1552
2017-05-19 12:04:02 +02:00
Rupert
a6a24abf13 portability: fixes needed to build on osx
Thanks to github user hdatma
2017-05-15 09:05:05 +02:00
PascalWithopf
a0a6e5bbba imfile: fix problem that fileNotFoundError was reported repeatedly in polling mode
fix https://github.com/rsyslog/rsyslog/issues/1534
2017-05-03 10:00:28 +02:00
PascalWithopf
3f789a4458 imfile: add error message when file is not found and parameter to disable this message 2017-05-02 10:54:56 +02:00
Rainer Gerhards
cc386e092f compatibility: fix warnings that occur on Solaris 2017-04-10 09:09:47 +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
cacf865621 core/file handling: add new error messages
Those messages previously went only to the debug log, as due to
design limitations inside the error message subsystem they could
not be emitted at the related code locations. This has changed now,
and so we can improve error reporting.
2017-03-15 17:44:03 +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
Damien Fleuriot
ee136aa582 bugfix: rsyslog loops on freebsd when trying to write /dev/console
Rsyslog 8.23.0 loops on FreeBSD when trying to access a (now revoked) /dev/console file descriptor, as per Alexandre's original bug report [1].

The original patch fixes the problem when tryTTYRecover() sees errno 6 ENXIO.

Running FreeBSD 10-stable here and getting errno 5 EIO, same as Xavier gets in his 2016 bug report [2].

New patch [3] includes errno 5 to tryTTYRecover() in runtime/stream.c and fixes the problem for me, on multiple machines.

[1] https://github.com/rsyslog/rsyslog/issues/371
[2] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211033
[3] https://bz-attachments.freebsd.org/attachment.cgi?id=178452

closes https://github.com/rsyslog/rsyslog/issues/1351
2017-01-18 18:58:59 +01:00
Pascal Withopf
b63a6b9010 codestyle: line length adjusted 2017-01-17 08:54:37 +01:00
Rainer Gerhards
d93fe1af36 bugfix: abort when persisting object state
This causes a segfault. It happens whenever an object state larger
than 4095 byte is persisted. Then, incorrectly a try to rollover to
a new state file is tried, which will lead to a division by zero
as the necessary variables for this operation are not set because we
are NOT in circular mode.

This problem can happen wherever state files are written. It has been
experienced with imfile and queue files.

Many thanks to github user mostolog for his help in reproducing the
issue, which was very important to finally nail down this long-standing
bug.

closes https://github.com/rsyslog/rsyslog/issues/1239
closes https://github.com/rsyslog/rsyslog/issues/1162
closes https://github.com/rsyslog/rsyslog/issues/1074
2016-11-02 18:59:23 +01:00
Rainer Gerhards
448f16495c remove "inline" attribute from excessivly long functions 2016-10-26 11:50:15 +02:00
Rainer Gerhards
bcbda82493 Merge pull request #1173 from rgerhards/i-1162
imfile: abort in stream handler
2016-10-20 12:24:03 +02:00
Rainer Gerhards
6efd4e3de2 core/stream.c: do not access private members without need 2016-10-18 15:56:49 +02:00
kordex
4af7e06166 core/stream.c: very, very slightly speed up multiline reads 2016-10-18 15:55:34 +02:00
Rainer Gerhards
4a578d3552 bugfix: theoretical queue file corruption when more than MAX_INT files
This also corrects some code areas that needed to be adapted to the
data type change done in the previous commit.

closes https://github.com/rsyslog/rsyslog/issues/1202
2016-10-18 15:48:15 +02:00
kordex
ed37e8b6de core: fix potential negative file numbers for queue files 2016-10-18 13:04:23 +02:00
Rainer Gerhards
41840bcd6d Merge pull request #1177 from rgerhards/merge-1161
Merge PR #1161
2016-10-10 16:48:46 +02:00
Rainer Gerhards
8eea909367 imfile: add "readTimeout" parameter
closes https://github.com/rsyslog/rsyslog/issues/1133
2016-10-10 15:45:45 +02:00
Rainer Gerhards
5088a1d3bf stream handling: better debug error assertion 2016-10-09 12:48:00 +02:00
hese10
6d051247e3 close/reopen file when write fails for specific error codes
When writing fails for file with error codes ENOTCONN or EIO, then file probably locates in network mounted partition, and thus needs to be closed and reopened.
2016-09-29 14:42:21 +03:00
Rainer Gerhards
51c03c66e0 make inline functions C99-compliant
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.
2016-09-05 16:47:14 +02:00
Rainer Gerhards
6a387869fa queue subsystem: improve debug messages 2016-08-22 16:20:02 +02:00
Rainer Gerhards
7d0116b7f3 internal: some better debug messages 2016-08-22 16:20:02 +02:00
Rainer Gerhards
bbcbb03c64 fix compiler warnings 2016-07-22 15:00:28 +02:00
Rainer Gerhards
a120a550f6 omfile: do not flag file name errors in dynafiles as error
This is a quick and dirty workaround; it is really hard to tell
what is the right thing to do in this case AND preserve existing
user configurations.
2016-06-21 14:19:57 +02:00
Rainer Gerhards
5e3b075d53 fix compiler warnings 2016-06-02 12:08:55 +02:00