88 lines
2.0 KiB
Diff
88 lines
2.0 KiB
Diff
From ad9108eaf9164225f9149ed2b3b5c3184e1cb487 Mon Sep 17 00:00:00 2001
|
|
From: Tomas Heinrich <theinric@redhat.com>
|
|
Date: Wed, 12 Jun 2013 13:38:34 +0200
|
|
Subject: [PATCH] bugfix: prevent a segfault if state file is not defined
|
|
|
|
---
|
|
plugins/imjournal/imjournal.c | 43 +++++++++++++++++++++++++++++------------
|
|
1 file changed, 31 insertions(+), 12 deletions(-)
|
|
|
|
diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c
|
|
index cce45b9..26b385c 100755
|
|
--- a/plugins/imjournal/imjournal.c
|
|
+++ b/plugins/imjournal/imjournal.c
|
|
@@ -434,12 +434,13 @@ finalize_it:
|
|
}
|
|
|
|
|
|
-BEGINrunInput
|
|
-CODESTARTrunInput
|
|
- /* this is an endless loop - it is terminated when the thread is
|
|
- * signalled to do so. This, however, is handled by the framework,
|
|
- * right into the sleep below.
|
|
- */
|
|
+/* This function loads a journal cursor from the state file.
|
|
+ */
|
|
+static rsRetVal
|
|
+loadJournalState()
|
|
+{
|
|
+ DEFiRet;
|
|
+
|
|
if (cs.stateFile[0] != '/') {
|
|
char *new_stateFile;
|
|
|
|
@@ -479,6 +480,20 @@ CODESTARTrunInput
|
|
}
|
|
}
|
|
|
|
+finalize_it:
|
|
+ RETiRet;
|
|
+}
|
|
+
|
|
+BEGINrunInput
|
|
+CODESTARTrunInput
|
|
+ /* this is an endless loop - it is terminated when the thread is
|
|
+ * signalled to do so. This, however, is handled by the framework.
|
|
+ */
|
|
+
|
|
+ if (cs.stateFile) {
|
|
+ CHKiRet(loadJournalState());
|
|
+ }
|
|
+
|
|
while (glbl.GetGlobalInputTermState() == 0) {
|
|
int count = 0, r;
|
|
|
|
@@ -499,11 +514,13 @@ CODESTARTrunInput
|
|
}
|
|
|
|
CHKiRet(readjournal());
|
|
- /* TODO: This could use some finer metric. */
|
|
- count++;
|
|
- if (count == cs.iPersistStateInterval) {
|
|
- count = 0;
|
|
- persistJournalState();
|
|
+ if (cs.stateFile) { /* can't persist without a state file */
|
|
+ /* TODO: This could use some finer metric. */
|
|
+ count++;
|
|
+ if (count == cs.iPersistStateInterval) {
|
|
+ count = 0;
|
|
+ persistJournalState();
|
|
+ }
|
|
}
|
|
}
|
|
|
|
@@ -552,7 +569,9 @@ ENDwillRun
|
|
/* close journal */
|
|
BEGINafterRun
|
|
CODESTARTafterRun
|
|
- persistJournalState();
|
|
+ if (cs.stateFile) { /* can't persist without a state file */
|
|
+ persistJournalState();
|
|
+ }
|
|
sd_journal_close(j);
|
|
ENDafterRun
|
|
|
|
--
|
|
1.7.10.4
|
|
|