summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Bartos <mbartos@redhat.com>2012-11-15 09:14:48 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2012-11-15 09:14:48 +0100
commit03c2dbc7c25316c377dbf70bfff564070f0441d2 (patch)
treecd4c888ea664d2cd243ddb15b33adc3f1dc3b612
parentc0f5dd3fbf877799ac8fec4d00b2f2c69014b413 (diff)
downloadrsyslog-03c2dbc7c25316c377dbf70bfff564070f0441d2.tar.gz
rsyslog-03c2dbc7c25316c377dbf70bfff564070f0441d2.tar.bz2
rsyslog-03c2dbc7c25316c377dbf70bfff564070f0441d2.zip
bugfix: imfile discarded some file parts
File lines that were incomplete (LF missing) *at the time imfile polled the file* were partially discarded. That part of the line that was read without the LF was discarded, and the rest of the line was submitted in the next polling cycle. This is now changed so that the partial content is saved until the complete line is read. Note that the patch affects only read mode 0.
-rw-r--r--ChangeLog8
-rw-r--r--runtime/stream.c27
2 files changed, 32 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 077e2b6f..1c6d6e94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -41,6 +41,14 @@ Version 7.2.2 [v7-stable] 2012-10-??
aborted on startup. Note that no segfault could happen if the initial
startup went well (this was a problem with the config parser).
closes: http://bugzilla.adiscon.com/show_bug.cgi?id=381
+- bugfix: imfile discarded some file parts
+ File lines that were incomplete (LF missing) *at the time imfile polled
+ the file* were partially discarded. That part of the line that was read
+ without the LF was discarded, and the rest of the line was submitted in
+ the next polling cycle. This is now changed so that the partial content
+ is saved until the complete line is read. Note that the patch affects
+ only read mode 0.
+ Thanks to Milan Bartos for providing the patch.
----------------------------------------------------------------------------
Version 7.2.1 [v7-stable] 2012-10-29
- bugfix: ruleset()-object did only support a single statement
diff --git a/runtime/stream.c b/runtime/stream.c
index 906a45fc..52d143de 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -589,19 +589,40 @@ strmReadLine(strm_t *pThis, cstr_t **ppCStr, int mode)
uchar c;
uchar finished;
+ rsRetVal readCharRet;
+
+ static cstr_t *prevCStr = NULL;
+
ASSERT(pThis != NULL);
ASSERT(ppCStr != NULL);
CHKiRet(cstrConstruct(ppCStr));
- /* now read the line */
+ /* append previous message to current message if necessary */
+ if (prevCStr != NULL) {
+ CHKiRet(cstrAppendCStr(*ppCStr, prevCStr));
+ }
+
CHKiRet(strmReadChar(pThis, &c));
if (mode == 0){
- while(c != '\n') {
+ while(c != '\n') {
CHKiRet(cstrAppendChar(*ppCStr, c));
- CHKiRet(strmReadChar(pThis, &c));
+
+ readCharRet = strmReadChar(pThis, &c);
+
+ /* end of file has been reached without \n */
+ if (readCharRet == RS_RET_EOF) {
+ CHKiRet(rsCStrConstructFromCStr(&prevCStr, *ppCStr));
+ }
+
+ CHKiRet(readCharRet);
}
CHKiRet(cstrFinalize(*ppCStr));
+ /* message has been finalized, destruct message from previous */
+ if (prevCStr) {
+ cstrDestruct(&prevCStr);
+ prevCStr = NULL;
+ }
}
if (mode == 1){
finished=0;