diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2012-09-24 18:59:26 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-09-24 18:59:26 +0200 |
commit | 8d99cfe38509aeadf169ba63c0d6c841eb2ecbe3 (patch) | |
tree | db53e6673a2f037de931283cec633c13eab1ea33 | |
parent | be26632b1e269652992ae6f336c5dd7e2dbec7ab (diff) | |
download | rsyslog-8d99cfe38509aeadf169ba63c0d6c841eb2ecbe3.tar.gz rsyslog-8d99cfe38509aeadf169ba63c0d6c841eb2ecbe3.tar.bz2 rsyslog-8d99cfe38509aeadf169ba63c0d6c841eb2ecbe3.zip |
Clean up implementation of omdiscard-->STOP optimization
-rw-r--r-- | action.c | 11 | ||||
-rw-r--r-- | grammar/rainerscript.c | 5 |
2 files changed, 13 insertions, 3 deletions
@@ -289,6 +289,11 @@ rsRetVal actionDestruct(action_t *pThis) DEFiRet; ASSERT(pThis != NULL); + if(!strcmp((char*)modGetName(pThis->pMod), "builtin:omdiscard")) { + /* discard actions will be optimized out */ + FINALIZE; + } + if(pThis->pQueue != NULL) { qqueueDestruct(&pThis->pQueue); } @@ -310,8 +315,8 @@ rsRetVal actionDestruct(action_t *pThis) d_free(pThis->pszName); d_free(pThis->ppTpl); +finalize_it: d_free(pThis); - RETiRet; } @@ -362,6 +367,10 @@ actionConstructFinalize(action_t *pThis, struct cnfparamvals *queueParams) ASSERT(pThis != NULL); + if(!strcmp((char*)modGetName(pThis->pMod), "builtin:omdiscard")) { + /* discard actions will be optimized out */ + FINALIZE; + } /* generate a friendly name for us action stats */ if(pThis->pszName == NULL) { snprintf((char*) pszAName, sizeof(pszAName)/sizeof(uchar), "action %d", iActionNbr); diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c index e5154156..ab07e0c4 100644 --- a/grammar/rainerscript.c +++ b/grammar/rainerscript.c @@ -2071,7 +2071,7 @@ cnfstmtOptimizeIf(struct cnfstmt *stmt) if(stmt->d.s_if.expr->nodetype == 'F') { func = (struct cnffunc*)expr; if(func->fID == CNFFUNC_PRIFILT) { - DBGPRINTF("optimize IF to PRIFILT\n"); + DBGPRINTF("optimizer: change IF to PRIFILT\n"); t_then = stmt->d.s_if.t_then; t_else = stmt->d.s_if.t_else; stmt->nodetype = S_PRIFILT; @@ -2095,7 +2095,8 @@ cnfstmtOptimizeAct(struct cnfstmt *stmt) pAct = stmt->d.act; if(!strcmp((char*)modGetName(stmt->d.act->pMod), "builtin:omdiscard")) { - DBGPRINTF("RainerScript Optimizer: replacing omdiscard by STOP\n"); + DBGPRINTF("optimizer: replacing omdiscard by STOP\n"); + actionDestruct(stmt->d.act); stmt->nodetype = S_STOP; } } |