summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-03-23 14:21:33 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-03-23 14:21:33 +0100
commit5d58774813d4ecd4fc9f8230f8d5446457eb2ed5 (patch)
tree5d2f549ccdf563bc4e9238a56d58a363284ab02f
parentf8dee56243d7378864fdcdcc21262fc563639827 (diff)
downloadrsyslog-5d58774813d4ecd4fc9f8230f8d5446457eb2ed5.tar.gz
rsyslog-5d58774813d4ecd4fc9f8230f8d5446457eb2ed5.tar.xz
rsyslog-5d58774813d4ecd4fc9f8230f8d5446457eb2ed5.zip
streamline dynafile cache entry deletion a bit
The old code looks a bit "strange", though not necessarily incorrect. The new code looks correct and is probably less irritating during bug hunting.
-rw-r--r--runtime/stream.c2
-rw-r--r--tools/omfile.c15
2 files changed, 8 insertions, 9 deletions
diff --git a/runtime/stream.c b/runtime/stream.c
index bfeecee5..e8805a40 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -722,7 +722,7 @@ CODESTARTobjDestruct(strm)
free(pThis->pZipBuf);
free(pThis->pszCurrFName);
free(pThis->pszFName);
-
+ pThis->bStopWriter = 2; /* RG: use as flag for destruction */
ENDobjDestruct(strm)
diff --git a/tools/omfile.c b/tools/omfile.c
index ae5f350d..91bcf0c2 100644
--- a/tools/omfile.c
+++ b/tools/omfile.c
@@ -286,19 +286,18 @@ dynaFileDelCacheEntry(dynaFileCacheEntry **pCache, int iEntry, int bFreeEntry)
DBGPRINTF("Removed entry %d for file '%s' from dynaCache.\n", iEntry,
pCache[iEntry]->pName == NULL ? UCHAR_CONSTANT("[OPEN FAILED]") : pCache[iEntry]->pName);
-// RG: check the "open failed" case -- can this cause trouble (but do we have that situation?)
- /* if the name is NULL, this is an improperly initialized entry which
- * needs to be discarded. In this case, neither the file is to be closed
- * nor the name to be freed.
- */
+
if(pCache[iEntry]->pName != NULL) {
- if(pCache[iEntry]->pStrm != NULL)
- strm.Destruct(&pCache[iEntry]->pStrm);
-// RG: pStrm should now be NULL...
d_free(pCache[iEntry]->pName);
pCache[iEntry]->pName = NULL;
}
+ if(pCache[iEntry]->pStrm != NULL) {
+ strm.Destruct(&pCache[iEntry]->pStrm);
+ if(pCache[iEntry]->pStrm != NULL) /* safety check -- TODO: remove if no longer necessary */
+ abort();
+ }
+
if(bFreeEntry) {
d_free(pCache[iEntry]);
pCache[iEntry] = NULL;