summaryrefslogtreecommitdiffstats
path: root/runtime/stream.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-01-10 08:22:50 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2011-01-10 08:22:50 +0100
commitcdc27aea8f9be98b3f886532191c73bfbc42b8a4 (patch)
tree36f83685462fc33a2b3f43319fe952ffae221600 /runtime/stream.c
parent25ff60f5238204ddde0eb7b76ca346372f496ba7 (diff)
downloadrsyslog-cdc27aea8f9be98b3f886532191c73bfbc42b8a4.tar.gz
rsyslog-cdc27aea8f9be98b3f886532191c73bfbc42b8a4.tar.xz
rsyslog-cdc27aea8f9be98b3f886532191c73bfbc42b8a4.zip
imfile bugfix: potential duplication of log content
Under some circumstances an invalid truncation was detected. This code has now been removed, a file change (and thus resent) is only detected if the inode number changes.
Diffstat (limited to 'runtime/stream.c')
-rw-r--r--runtime/stream.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/runtime/stream.c b/runtime/stream.c
index a2eeb039..af38bcb7 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -400,6 +400,12 @@ finalize_it:
* If we are monitoring a file, someone may have rotated it. In this case, we
* also need to close it and reopen it under the same name.
* rgerhards, 2008-02-13
+ * The previous code also did a check for file truncation, in which case the
+ * file was considered rewritten. However, this potential border case turned
+ * out to be a big trouble spot on busy systems. It caused massive message
+ * duplication (I guess stat() can return a too-low number under some
+ * circumstances). So starting as of now, we only check the inode number and
+ * a file change is detected only if the inode changes. -- rgerhards, 2011-01-10
*/
static rsRetVal
strmHandleEOFMonitor(strm_t *pThis)
@@ -409,24 +415,14 @@ strmHandleEOFMonitor(strm_t *pThis)
struct stat statName;
ISOBJ_TYPE_assert(pThis, strm);
- /* find inodes of both current descriptor as well as file now in file
- * system. If they are different, the file has been rotated (or
- * otherwise rewritten). We also check the size, because the inode
- * does not change if the file is truncated (this, BTW, is also a case
- * where we actually loose log lines, because we can not do anything
- * against truncation...). We do NOT rely on the time of last
- * modificaton because that may not be available under all
- * circumstances. -- rgerhards, 2008-02-13
- */
if(fstat(pThis->fd, &statOpen) == -1)
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",
+ DBGPRINTF("stream checking for file change on '%s', inode %u/%u",
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) {
+ (unsigned) statName.st_ino);
+ if(statOpen.st_ino == statName.st_ino) {
ABORT_FINALIZE(RS_RET_EOF);
} else {
/* we had a file change! */