summaryrefslogtreecommitdiffstats
path: root/runtime/stream.c
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 /runtime/stream.c
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.
Diffstat (limited to 'runtime/stream.c')
-rw-r--r--runtime/stream.c27
1 files changed, 24 insertions, 3 deletions
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;