summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2013-10-26 13:54:45 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2013-10-26 13:54:45 +0200
commitefa8dfb47da3ea46f06ab561aeb82ef1d6c3ee93 (patch)
tree853752612a18cbc37ec311e366d8a12cdfa07f31
parent71c851683b8911b2a6c37934dddff237902618bd (diff)
downloadrsyslog-efa8dfb47da3ea46f06ab561aeb82ef1d6c3ee93.tar.gz
rsyslog-efa8dfb47da3ea46f06ab561aeb82ef1d6c3ee93.tar.bz2
rsyslog-efa8dfb47da3ea46f06ab561aeb82ef1d6c3ee93.zip
maintain action ids (actionNbr)
-rw-r--r--action.c9
-rw-r--r--action.h4
-rw-r--r--runtime/rsconf.c1
-rw-r--r--runtime/wti.c8
-rw-r--r--runtime/wti.h1
5 files changed, 18 insertions, 5 deletions
diff --git a/action.c b/action.c
index eb6301d8..5f49b44c 100644
--- a/action.c
+++ b/action.c
@@ -175,10 +175,9 @@ configSettings_t cs_save; /* our saved (scope!) config settings */
/* the counter below counts actions created. It is used to obtain unique IDs for the action. They
* should not be relied on for any long-term activity (e.g. disk queue names!), but they are nice
* to have during one instance of an rsyslogd run. For example, I use them to name actions when there
- * is no better name available. Note that I do NOT recover previous numbers on HUP - we simply keep
- * counting. -- rgerhards, 2008-01-29
+ * is no better name available.
*/
-static int iActionNbr = 0;
+int iActionNbr = 0;
/* tables for interfacing with the v6 config system */
static struct cnfparamdescr cnfparamdescr[] = {
@@ -341,6 +340,7 @@ rsRetVal actionConstruct(action_t **ppThis)
pThis->bExecWhenPrevSusp = 0;
pThis->bRepMsgHasMsg = 0;
pThis->tLastOccur = datetime.GetTime(NULL); /* done once per action on startup only */
+ pThis->iActionNbr = iActionNbr;
pthread_mutex_init(&pThis->mutActExec, NULL);
pthread_mutex_init(&pThis->mutAction, NULL);
INIT_ATOMIC_HELPER_MUT(pThis->mutCAS);
@@ -912,7 +912,8 @@ actionCallDoAction(action_t *pThis, msg_t *pMsg, void *actParams)
ASSERT(pThis != NULL);
ISOBJ_TYPE_assert(pMsg, msg);
- DBGPRINTF("entering actionCalldoAction(), state: %s\n", getActStateName(pThis));
+ DBGPRINTF("entering actionCalldoAction(), state: %s, actionNbr %d\n",
+ getActStateName(pThis), pThis->iActionNbr);
pThis->bHadAutoCommit = 0;
iRet = pThis->pMod->mod.om.doAction(actParams, pMsg->msgFlags, pThis->pModData);
diff --git a/action.h b/action.h
index 54cdb54c..17b22942 100644
--- a/action.h
+++ b/action.h
@@ -51,6 +51,7 @@ struct action_s {
time_t tActNow; /* the current time for an action execution. Initially set to -1 and
populated on an as-needed basis. This is a performance optimization. */
time_t tLastExec; /* time this action was last executed */
+ int iActionNbr; /* this action's number (ID) */
sbool bExecWhenPrevSusp;/* execute only when previous action is suspended? */
sbool bWriteAllMarkMsgs;/* should all mark msgs be written (not matter how recent the action was executed)? */
int iSecsExecOnceInterval; /* if non-zero, minimum seconds to wait until action is executed again */
@@ -104,4 +105,7 @@ rsRetVal activateActions(void);
rsRetVal actionNewInst(struct nvlst *lst, action_t **ppAction);
rsRetVal actionProcessCnf(struct cnfobj *o);
+/* external data */
+extern int iActionNbr;
+
#endif /* #ifndef ACTION_H_INCLUDED */
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
index 8c808786..abce53b8 100644
--- a/runtime/rsconf.c
+++ b/runtime/rsconf.c
@@ -1205,6 +1205,7 @@ ourConf = loadConf; // TODO: remove, once ourConf is gone!
ABORT_FINALIZE(RS_RET_NO_ACTIONS);
}
tellLexEndParsing();
+ DBGPRINTF("Number of actions in this configuration: %d\n", iActionNbr);
rulesetOptimizeAll(loadConf);
tellCoreConfigLoadDone();
diff --git a/runtime/wti.c b/runtime/wti.c
index f91fb5a9..e9d3599d 100644
--- a/runtime/wti.c
+++ b/runtime/wti.c
@@ -44,6 +44,7 @@
#include "wti.h"
#include "obj.h"
#include "glbl.h"
+#include "action.h"
#include "atomic.h"
/* static data */
@@ -171,6 +172,7 @@ BEGINobjDestruct(wti) /* be sure to specify the object type also in END and CODE
CODESTARTobjDestruct(wti)
/* actual destruction */
batchFree(&pThis->batch);
+ free(pThis->actWrkrData);
DESTROY_ATOMIC_HELPER_MUT(pThis->mutIsRunning);
free(pThis->pszDbgHdr);
@@ -195,11 +197,15 @@ wtiConstructFinalize(wti_t *pThis)
ISOBJ_TYPE_assert(pThis, wti);
- DBGPRINTF("%s: finalizing construction of worker instance data\n", wtiGetDbgHdr(pThis));
+ DBGPRINTF("%s: finalizing construction of worker instance data (for %d actions)\n",
+ wtiGetDbgHdr(pThis), iActionNbr);
/* initialize our thread instance descriptor (no concurrency here) */
pThis->bIsRunning = RSFALSE;
+ /* must use calloc as we need zeto-init */
+ CHKmalloc(pThis->actWrkrData = calloc(iActionNbr, sizeof(void*)));
+
/* we now alloc the array for user pointers. We obtain the max from the queue itself. */
CHKiRet(pThis->pWtp->pfGetDeqBatchSize(pThis->pWtp->pUsr, &iDeqBatchSize));
CHKiRet(batchInit(&pThis->batch, iDeqBatchSize));
diff --git a/runtime/wti.h b/runtime/wti.h
index 014251f0..297fb999 100644
--- a/runtime/wti.h
+++ b/runtime/wti.h
@@ -37,6 +37,7 @@ struct wti_s {
wtp_t *pWtp; /* my worker thread pool (important if only the work thread instance is passed! */
batch_t batch; /* pointer to an object array meaningful for current user pointer (e.g. queue pUsr data elemt) */
uchar *pszDbgHdr; /* header string for debug messages */
+ void **actWrkrData; /* *array* of action wrkr data pointers (sized for max nbr of actions in config!) */
DEF_ATOMIC_HELPER_MUT(mutIsRunning);
};