summaryrefslogtreecommitdiffstats
path: root/plugins/imfile
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-08-14 11:19:02 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-08-14 11:19:02 +0200
commit7b456ce548030ff362d3a2be04b1e5c2c89e0dcb (patch)
treedbde3d8ff7515f5baf109c5ed17454e2f9665ab4 /plugins/imfile
parent8eb888d049da12e1294a7688432b6325794ade32 (diff)
downloadrsyslog-7b456ce548030ff362d3a2be04b1e5c2c89e0dcb.tar.gz
rsyslog-7b456ce548030ff362d3a2be04b1e5c2c89e0dcb.tar.xz
rsyslog-7b456ce548030ff362d3a2be04b1e5c2c89e0dcb.zip
bugfix: imfile could cause a segfault upon rsyslogd HUP and termination
Thanks to lperr for an excellent bug report that helped detect this problem.
Diffstat (limited to 'plugins/imfile')
-rw-r--r--plugins/imfile/imfile.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
index 75e54f04..6b7f516e 100644
--- a/plugins/imfile/imfile.c
+++ b/plugins/imfile/imfile.c
@@ -182,8 +182,9 @@ static void pollFileCancelCleanup(void *pArg)
/* poll a file, need to check file rollover etc. open file if not open */
static rsRetVal pollFile(fileInfo_t *pThis, int *pbHadFileData)
{
- DEFiRet;
cstr_t *pCStr = NULL;
+ int bMustPopCleanup = 0;
+ DEFiRet;
ASSERT(pbHadFileData != NULL);
@@ -192,6 +193,8 @@ static rsRetVal pollFile(fileInfo_t *pThis, int *pbHadFileData)
}
pthread_cleanup_push(pollFileCancelCleanup, &pCStr);
+ bMustPopCleanup = 1;
+
/* loop below will be exited when strmReadLine() returns EOF */
while(1) {
CHKiRet(strmReadLine(pThis->pStrm, &pCStr));
@@ -199,9 +202,11 @@ static rsRetVal pollFile(fileInfo_t *pThis, int *pbHadFileData)
CHKiRet(enqLine(pThis, pCStr)); /* process line */
rsCStrDestruct(&pCStr); /* discard string (must be done by us!) */
}
- pthread_cleanup_pop(0);
finalize_it:
+ if(bMustPopCleanup)
+ pthread_cleanup_pop(0);
+
if(pCStr != NULL) {
rsCStrDestruct(&pCStr);
}