201 Commits

Author SHA1 Message Date
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
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
Rainer Gerhards
445c7ec6df small speedup: do timeout computation only when actually needed
Thanks to Peter Portante for pointing this out.
2016-05-30 10:58:25 +02:00
Rainer Gerhards
3b0222c284 bugfix omfile: async output file writing does not respect flushing
neither parameter flushInterval nor flushOnTXEnd="on" was respected.

closes https://github.com/rsyslog/rsyslog/issues/1054
2016-05-27 14:49:01 +02:00
Rainer Gerhards
3099164ae7 core/file stream: fix misleading debug message
file object status was emitted before it was completely initialized
2016-05-27 12:05:51 +02:00
Rainer Gerhards
f8738727f9 change cstrFinalize() interface
the function can no longer fail and it is not expected that this
will ever happen again in the future. So we remove the return value,
giving a small speedup to the code.
2016-05-19 10:49:37 +02:00
Magnus Hyllander
cd7161ade8 append newline marker before the next line 2016-05-10 20:29:21 +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
1348225727 fix sign comparison build errors 2016-02-15 16:31:30 +01:00
Rainer Gerhards
42155cd5b4 Merge branch 'trim-line-over-bytes' of https://github.com/JindongChen/rsyslog into merge-664
Conflicts:
	runtime/stream.h
2016-02-15 15:45:40 +01:00
Rainer Gerhards
16f51bee3f Merge branch 'reopen-on-truncate' of https://github.com/ymattw/rsyslog into master-candidate 2016-01-14 08:13:21 -05:30
Rainer Gerhards
5087a50b0a refactor: remove or replace deprecated rsCStrGetSzStr() calls 2016-01-12 08:05:39 -05:30
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
Chen Jindong
7da93520ca Trim line when length of line over specified bytes 2015-12-11 13:58:37 +08:00
Rainer Gerhards
9e2762c57e fix return code check
we still ignore the return code, as this probably is the best we
can do in this case. Generating an error may result in a death spiral
or error messages. At least, we now output a message into the debug log.

Issue was detected by clang static analyzer.
2015-12-06 12:10:02 +01:00
Matthew Wang
ca79a68f04 Reopen truncated file with opt-in flag 'reopenOnTruncate'
Attempt to fix #511.  This is an enhanced version based on
https://github.com/rsyslog/rsyslog/pull/514, works fine for us so far.
As discussed before, I added an opt-in flag 'reopenOnTruncate' and
default is "off".
2015-12-03 20:24:35 +08:00
ed6ebe56fc stream driver: Fixed double mutex unlock when timeout git in asyncWriterThread
Also corrected mutex locking when timeout occurs, and removed never reached
mutex unlock.

closes https://github.com/rsyslog/rsyslog/issues/439
2015-11-30 08:14:40 -08:00
Rainer Gerhards
45c29a28be Merge branch 'queue-rsync-fixes' of https://github.com/alorbach/rsyslog-1 into master-candidate 2015-09-02 18:56:19 +02:00