diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2013-10-28 15:10:57 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-10-28 15:10:57 +0100 |
commit | 4cf5b6cb49385a3f5cdcbe34c534bbd4b89e4d8c (patch) | |
tree | f2dc9b440b02370868f2a0bafda3efc0707455ff | |
parent | f4161583cc799acfe5b5613e103418d1baaf450e (diff) | |
download | rsyslog-4cf5b6cb49385a3f5cdcbe34c534bbd4b89e4d8c.tar.gz rsyslog-4cf5b6cb49385a3f5cdcbe34c534bbd4b89e4d8c.tar.bz2 rsyslog-4cf5b6cb49385a3f5cdcbe34c534bbd4b89e4d8c.zip |
milestone: guard omfile writes by mutex
-rw-r--r-- | tools/omfile.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/omfile.c b/tools/omfile.c index 578407d1..424647e0 100644 --- a/tools/omfile.c +++ b/tools/omfile.c @@ -133,6 +133,7 @@ typedef struct s_dynaFileCacheEntry dynaFileCacheEntry; typedef struct _instanceData { + pthread_mutex_t mutWrite; /* guard against multiple instances writing to single file */ uchar *f_fname; /* file or template name (display only) */ uchar *tplName; /* name of assigned template */ strm_t *pStrm; /* our output stream */ @@ -806,6 +807,8 @@ writeFile(instanceData *pData, linebuf_t *linebuf) ASSERT(pData != NULL); + pthread_mutex_lock(&pData->mutWrite); + /* first check if we have a dynamic file name and, if so, * check if it still is ok or a new file needs to be created */ @@ -823,6 +826,7 @@ writeFile(instanceData *pData, linebuf_t *linebuf) CHKiRet(doWrite(pData, linebuf->ln, ustrlen(linebuf->ln))); finalize_it: + pthread_mutex_unlock(&pData->mutWrite); RETiRet; } @@ -902,6 +906,7 @@ ENDfreeCnf BEGINcreateInstance CODESTARTcreateInstance pData->pStrm = NULL; + pthread_mutex_init(&pData->mutWrite, NULL); ENDcreateInstance @@ -933,6 +938,7 @@ CODESTARTfreeInstance free(pData->cryprovName); free(pData->cryprovNameFull); } + pthread_mutex_destroy(&pData->mutWrite); ENDfreeInstance @@ -1390,6 +1396,7 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a BEGINdoHUP CODESTARTdoHUP + pthread_mutex_lock(&pData->mutWrite); if(pData->bDynamicName) { dynaFileFreeCacheEntries(pData); } else { @@ -1397,6 +1404,7 @@ CODESTARTdoHUP closeFile(pData); } } + pthread_mutex_unlock(&pData->mutWrite); ENDdoHUP |