summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-11-12 13:36:29 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2009-11-12 13:36:29 +0100
commitadab485b93a6bc87a90337f9f46dac1a9dfd62b1 (patch)
tree7ff7c12a27f26a6d1e89330c2d31c783a5f8b6fc
parent2dafb35077f013a22f0ce9d59306d8f59d709a51 (diff)
parent329b20451f0ed767dbf08903cab9a380ff1f4302 (diff)
downloadrsyslog-adab485b93a6bc87a90337f9f46dac1a9dfd62b1.tar.gz
rsyslog-adab485b93a6bc87a90337f9f46dac1a9dfd62b1.tar.xz
rsyslog-adab485b93a6bc87a90337f9f46dac1a9dfd62b1.zip
Merge branch 'v4-devel'
Conflicts: tests/Makefile.am
-rw-r--r--ChangeLog8
-rw-r--r--action.c3
-rw-r--r--tests/Makefile.am7
-rwxr-xr-xtests/execonlyonce.sh28
-rw-r--r--tests/testsuites/execonlyonce.conf12
-rw-r--r--tests/testsuites/execonlyonce.data2
6 files changed, 58 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 10945e2c..722faf05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,8 @@ Version 5.3.5 [DEVEL] (rgerhards), 2009-11-??
that could result in tests reporting success when they actually failed
- improved testbench: added tests for UDP forwarding and omudpspoof
- doc bugfix: omudpspoof had wrong config command names ("om" missing)
+- bugfix [imported from 4.4.3]: $ActionExecOnlyOnceEveryInterval did
+ not work.
- [inport v4] improved testbench, contains now tcp and gzip test cases
- [import v4] added a so-called "On Demand Debug" mode, in which debug
output can be generated only after the process has started, but not right
@@ -264,6 +266,8 @@ Version 4.5.7 [v4-beta] (rgerhards), 2009-11-??
be generated only after the process has started, but not right from
the beginning. This is assumed to be useful for hard-to-find bugs.
Also improved the doc on the debug system.
+- bugfix [imported from 4.4.3]: $ActionExecOnlyOnceEveryInterval did
+ not work.
---------------------------------------------------------------------------
Version 4.5.6 [v4-beta] (rgerhards), 2009-11-05
- bugfix: named pipes did no longer work (they always got an open error)
@@ -426,6 +430,10 @@ Version 4.5.0 [DEVEL] (rgerhards), 2009-07-02
an abort
---------------------------------------------------------------------------
Version 4.4.3 [v4-stable] (rgerhards), 2009-10-??
+- bugfix: $ActionExecOnlyOnceEveryInterval did not work.
+ This was a regression from the time() optimizations done in v4.
+ Bug tracker: http://bugzilla.adiscon.com/show_bug.cgi?id=143
+ Thanks to Klaus Tachtler for reporting this bug.
- bugfix: potential hang condition on queue shutdown
[imported from v3-stable]
---------------------------------------------------------------------------
diff --git a/action.c b/action.c
index 22615c2c..5958214f 100644
--- a/action.c
+++ b/action.c
@@ -1132,7 +1132,7 @@ actionWriteToAction(action_t *pAction)
* a purely logical point of view. However, if safes us to check the system time in
* (those common) cases where ExecOnceInterval is not used. -- rgerhards, 2008-09-16
*/
- if(pAction->f_time != 0 && pAction->iSecsExecOnceInterval > 0 &&
+ if(pAction->iSecsExecOnceInterval > 0 &&
pAction->iSecsExecOnceInterval + pAction->tLastExec > getActNow(pAction)) {
/* in this case we need to discard the message - its not yet time to exec the action */
DBGPRINTF("action not yet ready again to be executed, onceInterval %d, tCurr %d, tNext %d\n",
@@ -1143,6 +1143,7 @@ actionWriteToAction(action_t *pAction)
}
/* we use reception time, not dequeue time - this is considered more appropriate and also faster ;) -- rgerhards, 2008-09-17 */
+ pAction->tLastExec = getActNow(pAction); /* re-init time flags */
pAction->f_time = pAction->f_pMsg->ttGenTime;
/* When we reach this point, we have a valid, non-disabled action.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 24ad3f9a..62de7f28 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -18,7 +18,9 @@ TESTS = $(TESTRUNS) cfg.sh \
sndrcv_udp.sh \
sndrcv_udp_nonstdpt.sh \
queue-persist.sh \
- pipeaction.sh
+ pipeaction.sh \
+ execonlyonce.sh \
+ queue-persist.sh
if ENABLE_OMUDPSPOOF
TESTS += sndrcv_omudpspoof.sh \
@@ -188,6 +190,9 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
badqi.sh \
testsuites/badqi.conf \
bad_qi/dbq.qi \
+ execonlyonce.sh \
+ testsuites/execonlyonce.conf \
+ testsuites/execonlyonce.data \
DiagTalker.java \
cfg.sh
diff --git a/tests/execonlyonce.sh b/tests/execonlyonce.sh
new file mode 100755
index 00000000..a9b9d932
--- /dev/null
+++ b/tests/execonlyonce.sh
@@ -0,0 +1,28 @@
+# Test for the $ActionExecOnlyOnceEveryInterval directive.
+# We inject a couple of messages quickly during the interval,
+# then wait until the interval expires, then quickly inject
+# another set. After that, it is checked if exactly two messages
+# have arrived.
+# The once interval must be set to 3 seconds in the config file.
+# added 2009-11-12 by Rgerhards
+# This file is part of the rsyslog project, released under GPLv3
+echo ===============================================================================
+echo \[execonlyonce.sh\]: test for the $ActionExecOnlyOnceEveryInterval directive
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup execonlyonce.conf
+source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 10 1
+# now wait until the interval definitely expires
+sleep 4 # one more than the once inerval!
+# and inject another couple of messages
+source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 10 100
+source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
+
+# now we need your custom logic to see if the result is equal to the
+# expected result
+cmp rsyslog.out.log testsuites/execonlyonce.data
+if [ $? -eq 1 ]
+then
+ echo "ERROR, output not as expected"
+ exit 1
+fi
+source $srcdir/diag.sh exit
diff --git a/tests/testsuites/execonlyonce.conf b/tests/testsuites/execonlyonce.conf
new file mode 100644
index 00000000..085b970e
--- /dev/null
+++ b/tests/testsuites/execonlyonce.conf
@@ -0,0 +1,12 @@
+# see the equally-named .sh file for details
+# rgerhards, 2009-11-12
+$IncludeConfig diag-common.conf
+
+$ModLoad ../plugins/imtcp/.libs/imtcp
+$MainMsgQueueTimeoutShutdown 10000
+$InputTCPServerRun 13514
+
+$template outfmt,"%msg:F,58:2%\n"
+$template dynfile,"rsyslog.out.log" # trick to use relative path names!
+$ActionExecOnlyOnceEveryInterval 3
+:msg, contains, "msgnum:" ?dynfile;outfmt
diff --git a/tests/testsuites/execonlyonce.data b/tests/testsuites/execonlyonce.data
new file mode 100644
index 00000000..3c54f3d4
--- /dev/null
+++ b/tests/testsuites/execonlyonce.data
@@ -0,0 +1,2 @@
+00000001
+00000100