diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | grammar/rainerscript.c | 13 | ||||
-rw-r--r-- | grammar/rainerscript.h | 2 | ||||
-rw-r--r-- | runtime/ruleset.c | 26 | ||||
-rw-r--r-- | runtime/ruleset.h | 7 |
5 files changed, 46 insertions, 4 deletions
@@ -1,5 +1,7 @@ --------------------------------------------------------------------------- Version 7.4.2 [v7.4-stable] 2013-06-?? +- bugfix: call to ruleset with async queue did not use the queue + closes: http://bugzilla.adiscon.com/show_bug.cgi?id=443 - bugfix: RainerScript object required parameters were not properly checked - this clould result to segfaults on startup if parameters were missing. diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c index 95972fbe..a7828839 100644 --- a/grammar/rainerscript.c +++ b/grammar/rainerscript.c @@ -2274,7 +2274,8 @@ cnfstmtPrintOnly(struct cnfstmt *stmt, int indent, sbool subtree) break; case S_CALL: cstr = es_str2cstr(stmt->d.s_call.name, NULL); - doIndent(indent); dbgprintf("CALL [%s]\n", cstr); + doIndent(indent); dbgprintf("CALL [%s, queue:%d]\n", cstr, + stmt->d.s_call.ruleset == NULL ? 0 : 1); free(cstr); break; case S_ACT: @@ -3089,8 +3090,14 @@ cnfstmtOptimizeCall(struct cnfstmt *stmt) stmt->nodetype = S_NOP; goto done; } - DBGPRINTF("CALL obtained ruleset ptr %p for ruleset %s\n", pRuleset, rsName); - stmt->d.s_call.stmt = pRuleset->root; + DBGPRINTF("CALL obtained ruleset ptr %p for ruleset %s [hasQueue:%d]\n", + pRuleset, rsName, rulesetHasQueue(pRuleset)); + if(rulesetHasQueue(pRuleset)) { + stmt->d.s_call.ruleset = pRuleset; + } else { + stmt->d.s_call.ruleset = NULL; + stmt->d.s_call.stmt = pRuleset->root; + } done: free(rsName); return; diff --git a/grammar/rainerscript.h b/grammar/rainerscript.h index 31b2eb93..7debc420 100644 --- a/grammar/rainerscript.h +++ b/grammar/rainerscript.h @@ -5,6 +5,7 @@ #include <typedefs.h> #include <sys/types.h> #include <regex.h> +#include "typedefs.h" #define LOG_NFACILITIES 24 /* current number of syslog facilities */ @@ -164,6 +165,7 @@ struct cnfstmt { struct { es_str_t *name; struct cnfstmt *stmt; + ruleset_t *ruleset; /* non-NULL if the ruleset has a queue assigned */ } s_call; struct { uchar pmask[LOG_NFACILITIES+1]; /* priority mask */ diff --git a/runtime/ruleset.c b/runtime/ruleset.c index e3348938..cbfd847a 100644 --- a/runtime/ruleset.c +++ b/runtime/ruleset.c @@ -284,6 +284,30 @@ execStop(batch_t *pBatch, sbool *active) } RETiRet; } +static rsRetVal +execCall(struct cnfstmt *stmt, batch_t *pBatch, sbool *active) +{ + msg_t *pMsg; + int i; + DEFiRet; + if(stmt->d.s_call.ruleset == NULL) { + scriptExec(stmt->d.s_call.stmt, pBatch, active); + } else { + for(i = 0 ; i < batchNumMsgs(pBatch) ; ++i) { + CHKmalloc(pMsg = MsgDup((msg_t*) pBatch->pElem[i].pMsg)); + DBGPRINTF("CALL: forwarding message %d to async ruleset %p\n", + i, stmt->d.s_call.ruleset->pQueue); + MsgSetFlowControlType(pMsg, eFLOWCTL_NO_DELAY); + MsgSetRuleset(pMsg, stmt->d.s_call.ruleset); + /* Note: we intentionally use submitMsg2() here, as we process messages + * that were already run through the rate-limiter. + */ + submitMsg2(pMsg); + } + } +finalize_it: + RETiRet; +} /* for details, see scriptExec() header comment! */ // save current filter, evaluate new one @@ -535,7 +559,7 @@ scriptExec(struct cnfstmt *root, batch_t *pBatch, sbool *active) execUnset(stmt, pBatch, active); break; case S_CALL: - scriptExec(stmt->d.s_call.stmt, pBatch, active); + execCall(stmt, pBatch, active); break; case S_IF: execIf(stmt, pBatch, active); diff --git a/runtime/ruleset.h b/runtime/ruleset.h index cbf8243b..64fe92ff 100644 --- a/runtime/ruleset.h +++ b/runtime/ruleset.h @@ -90,6 +90,13 @@ rulesetGetName(ruleset_t *pRuleset) return pRuleset->pszName; } +/* returns 1 if the ruleset has a queue associtated, 0 if not */ +static inline int +rulesetHasQueue(ruleset_t *pRuleset) +{ + return pRuleset->pQueue == NULL ? 0 : 1; +} + /* we will most probably convert this module back to traditional C * calling sequence, so here we go... |