summaryrefslogtreecommitdiffstats
path: root/tools/omfile.c
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 /tools/omfile.c
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.
Diffstat (limited to 'tools/omfile.c')
-rw-r--r--tools/omfile.c15
1 files changed, 7 insertions, 8 deletions
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;