diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2012-09-21 10:41:05 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-09-21 10:41:05 +0200 |
commit | 87f415f16fec001a4f87e18817bace73f19d6416 (patch) | |
tree | 400d0e8ccd876cb40c1b6d59bc08b48a0034ae14 /runtime/ruleset.c | |
parent | bda0ef62f01ab86f5f4d84fb3d0eb25c14aaea55 (diff) | |
download | rsyslog-87f415f16fec001a4f87e18817bace73f19d6416.tar.gz rsyslog-87f415f16fec001a4f87e18817bace73f19d6416.tar.xz rsyslog-87f415f16fec001a4f87e18817bace73f19d6416.zip |
Implement script optimization IF -> PRIFILT
Diffstat (limited to 'runtime/ruleset.c')
-rw-r--r-- | runtime/ruleset.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/runtime/ruleset.c b/runtime/ruleset.c index ea8849e2..f37370b4 100644 --- a/runtime/ruleset.c +++ b/runtime/ruleset.c @@ -96,8 +96,12 @@ scriptIterateAllActions(struct cnfstmt *root, rsRetVal (*pFunc)(void*, void*), v pFunc, pParam); break; case S_PRIFILT: - scriptIterateAllActions(stmt->d.s_prifilt.t_then, - pFunc, pParam); + if(stmt->d.s_prifilt.t_then != NULL) + scriptIterateAllActions(stmt->d.s_prifilt.t_then, + pFunc, pParam); + if(stmt->d.s_prifilt.t_else != NULL) + scriptIterateAllActions(stmt->d.s_prifilt.t_else, + pFunc, pParam); break; case S_PROPFILT: scriptIterateAllActions(stmt->d.s_propfilt.t_then, @@ -313,11 +317,11 @@ execIf(struct cnfstmt *stmt, batch_t *pBatch, sbool *active) static void execPRIFILT(struct cnfstmt *stmt, batch_t *pBatch, sbool *active) { - sbool *thenAct; + sbool *newAct; msg_t *pMsg; int bRet; int i; - thenAct = newActive(pBatch); + newAct = newActive(pBatch); for(i = 0 ; i < batchNumMsgs(pBatch) && !*(pBatch->pbShutdownImmediate) ; ++i) { if(pBatch->pElem[i].state == BATCH_STATE_DISC) continue; /* will be ignored in any case */ @@ -331,12 +335,22 @@ execPRIFILT(struct cnfstmt *stmt, batch_t *pBatch, sbool *active) bRet = 1; } else bRet = 0; - thenAct[i] = bRet; - DBGPRINTF("batch: item %d PRIFILT %d\n", i, thenAct[i]); + newAct[i] = bRet; + DBGPRINTF("batch: item %d PRIFILT %d\n", i, newAct[i]); } - scriptExec(stmt->d.s_prifilt.t_then, pBatch, thenAct); - freeActive(thenAct); + if(stmt->d.s_prifilt.t_then != NULL) { + scriptExec(stmt->d.s_prifilt.t_then, pBatch, newAct); + } + if(stmt->d.s_prifilt.t_else != NULL) { + for(i = 0 ; i < batchNumMsgs(pBatch) && !*(pBatch->pbShutdownImmediate) + ; ++i) + if(pBatch->pElem[i].state != BATCH_STATE_DISC) +{ + newAct[i] = !newAct[i]; + scriptExec(stmt->d.s_prifilt.t_else, pBatch, newAct); + } + freeActive(newAct); } @@ -556,8 +570,6 @@ addScript(ruleset_t *pThis, struct cnfstmt *script) pThis->last->next = script; pThis->last = script; } -dbgprintf("RRRR: ruleset added script, script total now is:\n"); - cnfstmtPrint(pThis->root, 0); } |