summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/omfile.c16
-rw-r--r--tools/ompipe.c2
2 files changed, 12 insertions, 6 deletions
diff --git a/tools/omfile.c b/tools/omfile.c
index 150848eb..6a2d5e24 100644
--- a/tools/omfile.c
+++ b/tools/omfile.c
@@ -388,6 +388,7 @@ prepareFile(instanceData *pData, uchar *newFileName)
int fd;
DEFiRet;
+ pData->pStrm = NULL;
if(access((char*)newFileName, F_OK) == 0) {
if(pData->bForceChown) {
/* Try to fix wrong ownership set by someone else. Note that this code
@@ -473,6 +474,11 @@ prepareFile(instanceData *pData, uchar *newFileName)
CHKiRet(strm.ConstructFinalize(pData->pStrm));
finalize_it:
+ if(iRet != RS_RET_OK) {
+ if(pData->pStrm != NULL) {
+ strm.Destruct(&pData->pStrm);
+ }
+ }
RETiRet;
}
@@ -549,7 +555,7 @@ prepareDynFile(instanceData *pData, uchar *newFileName, unsigned iMsgOpts)
pData->iCurrElt = -1;
/* similarly, we need to set the current pStrm to NULL, because otherwise, if prepareFile() fails,
* we may end up using an old stream. This bug depends on how exactly prepareFile fails,
- * but it* could be triggered in the common case of a failed open() system call.
+ * but it could be triggered in the common case of a failed open() system call.
* rgerhards, 2010-03-22
*/
pData->pStrm = NULL;
@@ -577,8 +583,8 @@ prepareDynFile(instanceData *pData, uchar *newFileName, unsigned iMsgOpts)
/* Ok, we finally can open the file */
localRet = prepareFile(pData, newFileName); /* ignore exact error, we check fd below */
- /* file is either open now or an error state set */ // RG: better check localRet?
- if(pData->pStrm == NULL) {
+ /* check if we had an error */
+ if(localRet != RS_RET_OK) {
/* do not report anything if the message is an internally-generated
* message. Otherwise, we could run into a never-ending loop. The bad
* news is that we also lose errors on startup messages, but so it is.
@@ -586,7 +592,7 @@ prepareDynFile(instanceData *pData, uchar *newFileName, unsigned iMsgOpts)
if(iMsgOpts & INTERNAL_MSG) {
DBGPRINTF("Could not open dynaFile, discarding message\n");
} else {
- errmsg.LogError(0, NO_ERRCODE, "Could not open dynamic file '%s' - discarding message", newFileName);
+ errmsg.LogError(0, NO_ERRCODE, "Could not open dynamic file '%s' [state %d] - discarding message", newFileName, localRet);
}
ABORT_FINALIZE(localRet);
}
@@ -824,7 +830,7 @@ CODESTARTparseSelectorAct
if(pData->pStrm == NULL) {
DBGPRINTF("Error opening log file: %s\n", pData->f_fname);
- errmsg.LogError(0, RS_RET_NO_FILE_ACCESS, "Could no open output file '%s'", pData->f_fname);
+ errmsg.LogError(0, RS_RET_NO_FILE_ACCESS, "Could not open output file '%s'", pData->f_fname);
}
}
CODE_STD_FINALIZERparseSelectorAct
diff --git a/tools/ompipe.c b/tools/ompipe.c
index 58725fb9..469d7935 100644
--- a/tools/ompipe.c
+++ b/tools/ompipe.c
@@ -207,7 +207,7 @@ CODESTARTparseSelectorAct
if(pData->fd < 0 ) {
pData->fd = -1;
DBGPRINTF("Error opening log pipe: %s\n", pData->f_fname);
- errmsg.LogError(0, RS_RET_NO_FILE_ACCESS, "Could no open output pipe '%s'", pData->f_fname);
+ errmsg.LogError(0, RS_RET_NO_FILE_ACCESS, "Could not open output pipe '%s'", pData->f_fname);
}
CODE_STD_FINALIZERparseSelectorAct
ENDparseSelectorAct