From 2b665a5f631275ca3218d3fab6c8ac91b7880f81 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 18 Nov 2013 14:13:02 +0100 Subject: bugfix: potential segfault in omfile under heavy load --- ChangeLog | 2 ++ tools/omfile.c | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4111bf3..0538d657 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ --------------------------------------------------------------------------- Version 8.1.1 [devel] 2013-11-?? +- bugfix: potential segfault in omfile under heavy load + Thanks to Pavel Levshin for alerting us. - bugfix: mmsequence: instance mode did not work Thanks to Pavel Levshin for the patch - omhiredis: now supports v8 output module interface and works again diff --git a/tools/omfile.c b/tools/omfile.c index 1ee1026c..b1cbbfd9 100644 --- a/tools/omfile.c +++ b/tools/omfile.c @@ -979,10 +979,6 @@ submitCachedLines(wrkrInstanceData_t *pWrkrData, instanceData *pData) { linebuf_t *curr, *todel; -dbgprintf("omfile: waiting on write lock (pWrkrData %p)\n", pWrkrData); - pthread_mutex_lock(&pData->mutWrite); -dbgprintf("omfile: aquired write lock (pWrkrData %p)\n", pWrkrData); - for(curr = pWrkrData->pRoot ; curr != NULL ; ) { DBGPRINTF("omfile: file to log to: %s\n", curr->filename); DBGPRINTF("omfile: start of data: '%.128s'\n", curr->ln); @@ -995,8 +991,6 @@ dbgprintf("omfile: aquired write lock (pWrkrData %p)\n", pWrkrData); free(todel->ln); free(todel); } - pthread_mutex_unlock(&pData->mutWrite); -dbgprintf("omfile: free write lock (pWrkrData %p)\n", pWrkrData); pWrkrData->pRoot = NULL; } @@ -1016,6 +1010,10 @@ BEGINendTransaction instanceData *pData; CODESTARTendTransaction pData = pWrkrData->pData; +dbgprintf("omfile: waiting on write lock (pWrkrData %p)\n", pWrkrData); + pthread_mutex_lock(&pData->mutWrite); +dbgprintf("omfile: aquired write lock (pWrkrData %p)\n", pWrkrData); + submitCachedLines(pWrkrData, pData); /* Note: pStrm may be NULL if there was an error opening the stream */ if(pData->bFlushOnTXEnd && pData->pStrm != NULL) { @@ -1027,6 +1025,8 @@ CODESTARTendTransaction CHKiRet(strm.Flush(pData->pStrm)); } finalize_it: + pthread_mutex_unlock(&pData->mutWrite); +dbgprintf("omfile: free write lock (pWrkrData %p)\n", pWrkrData); ENDendTransaction -- cgit v1.2.3