78 lines
2.2 KiB
Diff
78 lines
2.2 KiB
Diff
From 4736e53d471ac45024333588fcdf5bce5f8c61b8 Mon Sep 17 00:00:00 2001
|
|
From: Rainer Gerhards <rgerhards@adiscon.com>
|
|
Date: Wed, 25 Oct 2017 11:09:40 +0200
|
|
Subject: [PATCH] imjournal bugfix: module did not work at all
|
|
|
|
The open function was broken by commit 92ac801 (v8.30.0),
|
|
resulting in no data being ever read from the journal.
|
|
|
|
patch bases on the idea of Radovan Sroka given here:
|
|
https://github.com/rsyslog/rsyslog/issues/1895#issuecomment-339017357
|
|
but follows the current imjournal-paradigm of having the journal
|
|
handle inside a global variable.
|
|
|
|
see also https://github.com/rsyslog/rsyslog/issues/1895
|
|
closes https://github.com/rsyslog/rsyslog/issues/1897
|
|
---
|
|
plugins/imjournal/imjournal.c | 16 ++++++++--------
|
|
1 file changed, 8 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c
|
|
index 8f043d5e1..2f1569837 100644
|
|
--- a/plugins/imjournal/imjournal.c
|
|
+++ b/plugins/imjournal/imjournal.c
|
|
@@ -118,20 +118,20 @@ static sd_journal *j;
|
|
static rsRetVal persistJournalState(void);
|
|
static rsRetVal loadJournalState(void);
|
|
|
|
-static rsRetVal openJournal(sd_journal* jj) {
|
|
+static rsRetVal openJournal(void) {
|
|
DEFiRet;
|
|
|
|
- if (sd_journal_open(&jj, SD_JOURNAL_LOCAL_ONLY) < 0)
|
|
+ if (sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY) < 0)
|
|
iRet = RS_RET_IO_ERROR;
|
|
RETiRet;
|
|
}
|
|
|
|
-static void closeJournal(sd_journal* jj) {
|
|
+static void closeJournal(void) {
|
|
|
|
if (cs.stateFile) { /* can't persist without a state file */
|
|
persistJournalState();
|
|
}
|
|
- sd_journal_close(jj);
|
|
+ sd_journal_close(j);
|
|
}
|
|
|
|
|
|
@@ -513,10 +513,10 @@ pollJournal(void)
|
|
/* do not persist stateFile sd_journal_get_cursor will fail! */
|
|
char* tmp = cs.stateFile;
|
|
cs.stateFile = NULL;
|
|
- closeJournal(j);
|
|
+ closeJournal();
|
|
cs.stateFile = tmp;
|
|
|
|
- iRet = openJournal(j);
|
|
+ iRet = openJournal();
|
|
if (iRet != RS_RET_OK) {
|
|
char errStr[256];
|
|
rs_strerror_r(errno, errStr, sizeof(errStr));
|
|
@@ -773,13 +773,13 @@ ENDfreeCnf
|
|
/* open journal */
|
|
BEGINwillRun
|
|
CODESTARTwillRun
|
|
- iRet = openJournal(j);
|
|
+ iRet = openJournal();
|
|
ENDwillRun
|
|
|
|
/* close journal */
|
|
BEGINafterRun
|
|
CODESTARTafterRun
|
|
- closeJournal(j);
|
|
+ closeJournal();
|
|
ratelimitDestruct(ratelimiter);
|
|
ENDafterRun
|
|
|