diff options
-rw-r--r-- | action.c | 27 | ||||
-rw-r--r-- | action.h | 1 | ||||
-rw-r--r-- | runtime/msg.c | 4 | ||||
-rw-r--r-- | template.c | 32 |
4 files changed, 6 insertions, 58 deletions
@@ -1213,9 +1213,8 @@ prepareBatch(action_t *pAction, batch_t *pBatch, sbool **activeSave, int *bMustR struct syslogTime ttNow; DEFiRet; - if(pAction->requiresDateCall) { - datetime.getCurrTime(&ttNow, NULL); - } + /* indicate we have not yet read the date */ + ttNow.year = 0; pBatch->iDoneUpTo = 0; for(i = 0 ; i < batchNumMsgs(pBatch) && !*(pBatch->pbShutdownImmediate) ; ++i) { @@ -1771,27 +1770,6 @@ actionApplyCnfParam(action_t *pAction, struct cnfparamvals *pvals) return RS_RET_OK; } -/* check if the templates used in this action require a date call - * ($NOW family of properties). - */ -static inline int -actionRequiresDateCall(action_t *pAction) -{ - int i; - int r = 0; - - if(pAction->eParamPassing == ACT_MSG_PASSING) - /* in msg passing mode, we have NO templates! */ - goto done; - for(i = 0 ; i < pAction->iNumTpls ; ++i) { - if(tplRequiresDateCall(pAction->ppTpl[i])) { - r = 1; - break; - } - } -done: return r; -} - /* add an Action to the current selector * The pOMSR is freed, as it is not needed after this function. @@ -1890,7 +1868,6 @@ addAction(action_t **ppAction, modInfo_t *pMod, void *pModData, pAction->pModData = pModData; /* check if the module is compatible with select features (currently no such features exist) */ pAction->eState = ACT_STATE_RDY; /* action is enabled */ - pAction->requiresDateCall = actionRequiresDateCall(pAction); if(bSuspended) actionSuspend(pAction, datetime.GetTime(NULL)); /* "good" time call, only during init and unavoidable */ @@ -68,7 +68,6 @@ struct action_s { struct modInfo_s *pMod;/* pointer to output module handling this selector */ void *pModData; /* pointer to module data - content is module-specific */ sbool bRepMsgHasMsg; /* "message repeated..." has msg fragment in it (0-no, 1-yes) */ - sbool requiresDateCall;/* do we need to do a date call before creating templates? */ rsRetVal (*submitToActQ)(action_t *, batch_t *);/* function submit message to action queue */ rsRetVal (*qConstruct)(struct queue_s *pThis); enum { ACT_STRING_PASSING = 0, ACT_ARRAY_PASSING = 1, ACT_MSG_PASSING = 2, diff --git a/runtime/msg.c b/runtime/msg.c index 37df5bd0..d16bbb75 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -2456,6 +2456,10 @@ static uchar *getNOW(eNOWType eNow, struct syslogTime *t) return NULL; } + if(t->year == 0) { /* not yet set! */ + datetime.getCurrTime(t, NULL); + } + switch(eNow) { case NOW_NOW: snprintf((char*) pBuf, tmpBUFSIZE, "%4.4d-%2.2d-%2.2d", t->year, t->month, t->day); @@ -376,38 +376,6 @@ finalize_it: } -/* Check if the template requires a date call (actually a cached - * date structure). This currently is the case for the $NOW family - * of properties. - */ -int -tplRequiresDateCall(struct template *pTpl) -{ - struct templateEntry *pTpe; - int r = 0; - - if(pTpl->subtree != NULL) - goto done; - - for(pTpe = pTpl->pEntryRoot ; pTpe != NULL ; pTpe = pTpe->pNext) { - switch(pTpe->data.field.propid) { - case PROP_SYS_NOW: - case PROP_SYS_YEAR: - case PROP_SYS_MONTH: - case PROP_SYS_DAY: - case PROP_SYS_HOUR: - case PROP_SYS_HHOUR: - case PROP_SYS_QHOUR: - case PROP_SYS_MINUTE: - r = 1; - goto done; - default:break; - } - } -done: return r; -} - - /* Helper to doEscape. This is called if doEscape * runs out of memory allocating the escaped string. * Then we are in trouble. We can |