summaryrefslogtreecommitdiffstats
path: root/runtime/stream.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-12-17 18:18:57 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-12-17 18:18:57 +0100
commit50855878062dbcf8d2861ea169d3ca686c65b23b (patch)
treed1baedc207c6adadb3f18501c8ffd49508b1b936 /runtime/stream.c
parent371a8eec29fa25bbf58f4b1f0d7e3bf4c3ad6329 (diff)
downloadrsyslog-50855878062dbcf8d2861ea169d3ca686c65b23b.tar.gz
rsyslog-50855878062dbcf8d2861ea169d3ca686c65b23b.tar.xz
rsyslog-50855878062dbcf8d2861ea169d3ca686c65b23b.zip
bugfix: imfile potentially duplicates lines
This can happen when 0 bytes are read from the input file, and some writer appends data to the file BEFORE we check if a rollover happens. The check for rollover uses the inode and size as a criterion. So far, we checked for equality of sizes, which is not given in this scenario, but that does not indicate a rollover. From the source code comments: Note that when we check the size, we MUST NOT check for equality. The reason is that the file may have been written right after we did try to read (so the file size has increased). That is NOT in indicator of a rollover (this is an actual bug scenario we experienced). So we need to check if the new size is smaller than what we already have seen!
Diffstat (limited to 'runtime/stream.c')
-rw-r--r--runtime/stream.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/runtime/stream.c b/runtime/stream.c
index 869324ec..baf69881 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -422,10 +422,15 @@ strmHandleEOFMonitor(strm_t *pThis)
ABORT_FINALIZE(RS_RET_IO_ERROR);
if(stat((char*) pThis->pszCurrFName, &statName) == -1)
ABORT_FINALIZE(RS_RET_IO_ERROR);
+ DBGPRINTF("stream checking for file change on '%s', inode %u/%u, size %lld/%lld\n",
+ pThis->pszCurrFName, (unsigned) statOpen.st_ino,
+ (unsigned) statName.st_ino,
+ pThis->iCurrOffs, (long long) statName.st_size);
if(statOpen.st_ino == statName.st_ino && pThis->iCurrOffs == statName.st_size) {
ABORT_FINALIZE(RS_RET_EOF);
} else {
/* we had a file change! */
+ DBGPRINTF("we had a file change on '%s'\n", pThis->pszCurrFName);
CHKiRet(strmCloseFile(pThis));
CHKiRet(strmOpenFile(pThis));
}