summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-03-23 07:10:03 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-03-23 07:10:03 +0100
commitd2f242edcb25e69ae7de5a142229330070f2e70b (patch)
tree8f25fa8de784c877cda4c17452955234cdc2f95e /tools
parent396e211e5cfd195b7135947d425b089a0447fa88 (diff)
parent2f1d5a12037453792eb1000c79daf737b41c5ba4 (diff)
downloadrsyslog-d2f242edcb25e69ae7de5a142229330070f2e70b.tar.gz
rsyslog-d2f242edcb25e69ae7de5a142229330070f2e70b.tar.xz
rsyslog-d2f242edcb25e69ae7de5a142229330070f2e70b.zip
Merge branch 'v4-stable' into v4-stable-solaris
Diffstat (limited to 'tools')
-rw-r--r--tools/omfile.c20
-rw-r--r--tools/omfwd.c4
-rw-r--r--tools/zpipe.c7
3 files changed, 24 insertions, 7 deletions
diff --git a/tools/omfile.c b/tools/omfile.c
index eb56201c..0f27f1e9 100644
--- a/tools/omfile.c
+++ b/tools/omfile.c
@@ -48,6 +48,7 @@
#include <libgen.h>
#include <unistd.h>
#include <sys/file.h>
+#include <pthread.h>
#ifdef OS_SOLARIS
# include <fcntl.h>
@@ -65,6 +66,7 @@
#include "stream.h"
#include "unicode-helper.h"
#include "atomic.h"
+#include "debug.h"
MODULE_TYPE_OUTPUT
@@ -79,7 +81,7 @@ DEFobjCurrIf(strm)
struct s_dynaFileCacheEntry {
uchar *pName; /* name currently open, if dynamic name */
strm_t *pStrm; /* our output stream */
- time_t lastUsed; /* for LRU - last access */ // TODO: perforamcne change to counter (see other comment!)
+ time_t lastUsed; /* for LRU - last access */
};
typedef struct s_dynaFileCacheEntry dynaFileCacheEntry;
@@ -99,7 +101,7 @@ static uid_t dirGID; /* GID to be used for newly created directories */
static int bCreateDirs = 1;/* auto-create directories for dynaFiles: 0 - no, 1 - yes */
static int bEnableSync = 0;/* enable syncing of files (no dash in front of pathname in conf): 0 - no, 1 - yes */
static int iZipLevel = 0; /* zip compression mode (0..9 as usual) */
-static bool bFlushOnTXEnd = 1;/* flush write buffers when transaction has ended? */
+static bool bFlushOnTXEnd = 0;/* flush write buffers when transaction has ended? */
static int64 iIOBufSize = IOBUF_DFLT_SIZE; /* size of an io buffer */
static int iFlushInterval = FLUSH_INTRVL_DFLT; /* how often flush the output buffer on inactivity? */
uchar *pszFileDfltTplName = NULL; /* name of the default template to use */
@@ -134,6 +136,7 @@ typedef struct _instanceData {
int iIOBufSize; /* size of associated io buffer */
int iFlushInterval; /* how fast flush buffer on inactivity? */
bool bFlushOnTXEnd; /* flush write buffers when transaction has ended? */
+ pthread_mutex_t mutEx; /* guard ourselves against being called multiple times with the same instance */
} instanceData;
@@ -532,7 +535,7 @@ prepareDynFile(instanceData *pData, uchar *newFileName, unsigned iMsgOpts)
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
}
pCache[iFirstFree]->pStrm = pData->pStrm;
- pCache[iFirstFree]->lastUsed = time(NULL); // monotonically increasing value! TODO: performance
+ pCache[iFirstFree]->lastUsed = time(NULL);
pData->iCurrElt = iFirstFree;
DBGPRINTF("Added new entry %d for file cache, file '%s'.\n", iFirstFree, newFileName);
@@ -603,6 +606,7 @@ finalize_it:
BEGINcreateInstance
CODESTARTcreateInstance
pData->pStrm = NULL;
+ pthread_mutex_init(&pData->mutEx, NULL);
ENDcreateInstance
@@ -612,6 +616,7 @@ CODESTARTfreeInstance
dynaFileFreeCache(pData);
} else if(pData->pStrm != NULL)
strm.Destruct(&pData->pStrm);
+ pthread_mutex_destroy(&pData->mutEx);
ENDfreeInstance
@@ -621,6 +626,7 @@ ENDtryResume
BEGINdoAction
CODESTARTdoAction
+ d_pthread_mutex_lock(&pData->mutEx);
DBGPRINTF("file to log to: %s\n", pData->f_fname);
CHKiRet(writeFile(ppString, iMsgOpts, pData));
if(pData->bFlushOnTXEnd) {
@@ -628,12 +634,13 @@ CODESTARTdoAction
CHKiRet(strm.Flush(pData->pStrm));
}
finalize_it:
+ d_pthread_mutex_unlock(&pData->mutEx);
ENDdoAction
BEGINparseSelectorAct
CODESTARTparseSelectorAct
- if(!(*p == '$' || *p == '?' || *p == '/' || *p == '-'))
+ if(!(*p == '$' || *p == '?' || *p == '/' || *p == '.' || *p == '-'))
ABORT_FINALIZE(RS_RET_CONFLINE_UNPROCESSED);
CHKiRet(createInstance(&pData));
@@ -683,6 +690,7 @@ CODESTARTparseSelectorAct
* need high-performance pipes at a later stage (unlikely). -- rgerhards, 2010-02-28
*/
case '/':
+ case '.':
CODE_STD_STRING_REQUESTparseSelectorAct(1)
/* we now have *almost* the same semantics for files and pipes, but we still need
* to know we deal with a pipe, because we must do non-blocking opens in that case
@@ -749,7 +757,7 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
bCreateDirs = 1;
bEnableSync = 0;
iZipLevel = 0;
- bFlushOnTXEnd = 1;
+ bFlushOnTXEnd = 0;
iIOBufSize = IOBUF_DFLT_SIZE;
iFlushInterval = FLUSH_INTRVL_DFLT;
if(pszFileDfltTplName != NULL) {
@@ -763,6 +771,7 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
BEGINdoHUP
CODESTARTdoHUP
+ d_pthread_mutex_lock(&pData->mutEx);
if(pData->bDynamicName) {
dynaFileFreeCacheEntries(pData);
} else {
@@ -771,6 +780,7 @@ CODESTARTdoHUP
pData->pStrm = NULL;
}
}
+ d_pthread_mutex_unlock(&pData->mutEx);
ENDdoHUP
diff --git a/tools/omfwd.c b/tools/omfwd.c
index a6d83eb9..cbfc36a4 100644
--- a/tools/omfwd.c
+++ b/tools/omfwd.c
@@ -411,7 +411,7 @@ CODESTARTtryResume
ENDtryResume
BEGINdoAction
- char *psz; /* temporary buffering */
+ char *psz = NULL; /* temporary buffering */
register unsigned l;
int iMaxLine;
CODESTARTdoAction
@@ -487,7 +487,7 @@ CODESTARTdoAction
}
finalize_it:
# ifdef USE_NETZIP
- if(psz != (char*) ppString[0]) {
+ if((psz != NULL) && (psz != (char*) ppString[0])) {
/* we need to free temporary buffer, alloced above - Naoya Nakazawa, 2010-01-11 */
free(psz);
}
diff --git a/tools/zpipe.c b/tools/zpipe.c
index d2278359..38069425 100644
--- a/tools/zpipe.c
+++ b/tools/zpipe.c
@@ -4,6 +4,13 @@
Version 2.0 03 June 2009 Rainer Gerhards */
/* RSYSLOG NOTE:
+ * This file is primarily been used as a testing aid for rsyslog. We do NOT
+ * properly maintain it and it has been brought to our attention that it may
+ * have some security issues. However, we prefer not to remove the file as it
+ * may turn out to be useful for further testing. All users are advised NOT
+ * to base any development on this version here, but rather look for the
+ * original zpipe.c by the authors mentioned above.
+ *
* This file is beeing distributed as part of rsyslog, but is just an
* add-on. Most importantly, rsyslog's copyright does not apply but
* rather the (non-) copyright stated above.