From 35bafbef04a8f7ba56abebbed337f79b8d6dd67f Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 20 Mar 2013 17:05:18 +0100 Subject: imfile: now detects file change when rsyslog was inactive Previosly, this case could not be detected, so if a file was overwritten or rotated away while rsyslog was stopped, some data was missing. This is now detected and the new file being forwarded right from the beginning. closes: http://bugzilla.adiscon.com/show_bug.cgi?id=228 --- plugins/imfile/imfile.c | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins/imfile/imfile.c') diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c index 0f155c10..6ce08fd4 100644 --- a/plugins/imfile/imfile.c +++ b/plugins/imfile/imfile.c @@ -235,6 +235,7 @@ openFile(fileInfo_t *pThis) /* read back in the object */ CHKiRet(obj.Deserialize(&pThis->pStrm, (uchar*) "strm", psSF, NULL, pThis)); + strm.CheckFileChange(pThis->pStrm); CHKiRet(strm.SeekCurrOffs(pThis->pStrm)); /* note: we do not delete the state file, so that the last position remains -- cgit v1.2.3 From b96674bbc9439f107c700d75e69268ee75e0387e Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 20 Mar 2013 18:10:17 +0100 Subject: imfile: errors persisting state file are now reported closes: http://bugzilla.adiscon.com/show_bug.cgi?id=292 --- plugins/imfile/imfile.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'plugins/imfile/imfile.c') diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c index 6ce08fd4..349acead 100644 --- a/plugins/imfile/imfile.c +++ b/plugins/imfile/imfile.c @@ -739,12 +739,20 @@ persistStrmState(fileInfo_t *pInfo) CHKiRet(strm.ConstructFinalize(psSF)); CHKiRet(strm.Serialize(pInfo->pStrm, psSF)); + CHKiRet(strm.Flush(psSF)); CHKiRet(strm.Destruct(&psSF)); finalize_it: if(psSF != NULL) strm.Destruct(&psSF); + + if(iRet != RS_RET_OK) { + errmsg.LogError(0, iRet, "imfile: could not persist state " + "file %s - data may be repeated on next " + "startup. Is WorkDirectory set?", + pInfo->pszStateFile); + } RETiRet; } -- cgit v1.2.3