diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2013-06-15 10:15:00 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-06-15 10:15:00 +0200 |
commit | 44a45748ce5a17e39da9af29fe9a8af9ba821c28 (patch) | |
tree | c075cb49acdccee1600fdfc85f389f7e4300a6b9 /plugins/imjournal/imjournal.c | |
parent | 99ce83604aed4dbaa46045335b527d09e41a846d (diff) | |
parent | f0f1a53a1650eb00e8f071d269bbe63bca285169 (diff) | |
download | rsyslog-44a45748ce5a17e39da9af29fe9a8af9ba821c28.tar.gz rsyslog-44a45748ce5a17e39da9af29fe9a8af9ba821c28.tar.bz2 rsyslog-44a45748ce5a17e39da9af29fe9a8af9ba821c28.zip |
Merge branch 'v7-stable'
Diffstat (limited to 'plugins/imjournal/imjournal.c')
-rwxr-xr-x | plugins/imjournal/imjournal.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c index cce45b9c..26b385ca 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 |