summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-08-15 14:02:07 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-08-15 14:02:07 +0200
commitc2f30a2fc3fb1f87c157828dd08ee20fe444833d (patch)
tree6ed707814022350d1313558d28059d7aba0e0631 /plugins
parent8aa2b21f7fc97e09c02f40815be6e4635ec080ba (diff)
parent9b46c03ce20c2d074bafdd68840461ed89b35ef4 (diff)
downloadrsyslog-c2f30a2fc3fb1f87c157828dd08ee20fe444833d.tar.gz
rsyslog-c2f30a2fc3fb1f87c157828dd08ee20fe444833d.tar.xz
rsyslog-c2f30a2fc3fb1f87c157828dd08ee20fe444833d.zip
Merge branch 'beta'
Conflicts: ChangeLog
Diffstat (limited to 'plugins')
-rw-r--r--plugins/imfile/imfile.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
index dbdf6b94..3bc07b9c 100644
--- a/plugins/imfile/imfile.c
+++ b/plugins/imfile/imfile.c
@@ -187,16 +187,19 @@ static void pollFileCancelCleanup(void *pArg)
#pragma GCC diagnostic ignored "-Wempty-body"
static rsRetVal pollFile(fileInfo_t *pThis, int *pbHadFileData)
{
- DEFiRet;
cstr_t *pCStr = NULL;
+ DEFiRet;
ASSERT(pbHadFileData != NULL);
+ /* Note: we must do pthread_cleanup_push() immediately, because the POXIS macros
+ * otherwise do not work if I include the _cleanup_pop() inside an if... -- rgerhards, 2008-08-14
+ */
+ pthread_cleanup_push(pollFileCancelCleanup, &pCStr);
if(pThis->pStrm == NULL) {
CHKiRet(openFile(pThis)); /* open file */
}
- pthread_cleanup_push(pollFileCancelCleanup, &pCStr);
/* loop below will be exited when strmReadLine() returns EOF */
while(1) {
CHKiRet(strmReadLine(pThis->pStrm, &pCStr));
@@ -204,9 +207,18 @@ 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:
+ /*EMPTY - just to keep the compiler happy, do NOT remove*/;
+ /* Note: the problem above is that pthread:cleanup_pop() is a macro which
+ * evaluates to something like "} while(0);". So the code would become
+ * "finalize_it: }", that is a label without a statement. The C standard does
+ * not permit this. So we add an empty statement "finalize_it: ; }" and
+ * everybody is happy. Note that without the ;, an error is reported only
+ * on some platforms/compiler versions. -- rgerhards, 2008-08-15
+ */
+ pthread_cleanup_pop(0);
+
if(pCStr != NULL) {
rsCStrDestruct(&pCStr);
}