Beispiel #1
0
/* generate a "repeated n times" message */
static smsg_t *
ratelimitGenRepMsg(ratelimit_t *ratelimit)
{
	smsg_t *repMsg;
	size_t lenRepMsg;
	uchar szRepMsg[1024];

	if(ratelimit->nsupp == 1) { /* we simply use the original message! */
		repMsg = MsgAddRef(ratelimit->pMsg);
	} else {/* we need to duplicate, original message may still be in use in other
		 * parts of the system!  */
		if((repMsg = MsgDup(ratelimit->pMsg)) == NULL) {
			DBGPRINTF("Message duplication failed, dropping repeat message.\n");
			goto done;
		}
		lenRepMsg = snprintf((char*)szRepMsg, sizeof(szRepMsg),
					" message repeated %d times: [%.800s]",
					ratelimit->nsupp, getMSG(ratelimit->pMsg));
		MsgReplaceMSG(repMsg, szRepMsg, lenRepMsg);
	}

done:	return repMsg;
}
Beispiel #2
0
	dbgprintf("omruleset target %s[%p]\n", (char*) pData->pszRulesetName, pData->pRuleset);
ENDdbgPrintInstInfo


BEGINtryResume
CODESTARTtryResume
ENDtryResume

/* Note that we change the flow control type to "no delay", because at this point in 
 * rsyslog procesing we can not really slow down the producer any longer, as we already
 * work off a queue. So a delay would just block out execution for longer than needed.
 */
BEGINdoAction
	msg_t *pMsg;
CODESTARTdoAction
	CHKmalloc(pMsg = MsgDup((msg_t*) ppString[0]));
	DBGPRINTF(":omruleset: forwarding message %p to ruleset %s[%p]\n", pMsg,
		  (char*) pData->pszRulesetName, pData->pRuleset);
	MsgSetFlowControlType(pMsg, eFLOWCTL_NO_DELAY);
	MsgSetRuleset(pMsg, pData->pRuleset);
	/* Note: we intentionally use submitMsg2() here, as we process messages
	 * that were already run through the rate-limiter. So it is (at least)
	 * questionable if they were rate-limited again.
	 */
	submitMsg2(pMsg);
finalize_it:
ENDdoAction

/* set the ruleset name */
static rsRetVal
setRuleset(void __attribute__((unused)) *pVal, uchar *pszName)