diff options
-rw-r--r-- | module-template.h | 25 | ||||
-rw-r--r-- | modules.c | 4 | ||||
-rw-r--r-- | modules.h | 1 | ||||
-rw-r--r-- | omdiscard.c | 4 | ||||
-rw-r--r-- | omfile.c | 4 | ||||
-rw-r--r-- | omfwd.c | 21 | ||||
-rw-r--r-- | ommysql.c | 4 | ||||
-rw-r--r-- | omshell.c | 4 | ||||
-rw-r--r-- | omusrmsg.c | 4 | ||||
-rw-r--r-- | syslogd.c | 13 | ||||
-rw-r--r-- | syslogd.h | 17 |
11 files changed, 82 insertions, 19 deletions
diff --git a/module-template.h b/module-template.h index 9cad16ff..2ef4a174 100644 --- a/module-template.h +++ b/module-template.h @@ -235,6 +235,29 @@ do_abort:\ } +/* tryResume() + * This entry point is called to check if a module can resume operations. This + * happens when a module requested that it be suspended. In suspended state, + * the engine periodically tries to resume the module. If that succeeds, normal + * processing continues. If not, the module will not be called unless a + * tryResume() call succeeds. + * Returns RS_RET_OK, if resumption succeeded, RS_RET_SUSPENDED otherwise + * rgerhard, 2007-08-02 + */ +#define BEGINtryResume \ +static rsRetVal tryResume(instanceData __attribute__((unused)) *pData)\ +{\ + DEFiRet; + +#define CODESTARTtryResume \ + assert(pData != NULL); + +#define ENDtryResume \ + return iRet;\ +} + + + /* queryEtryPt() */ #define BEGINqueryEtryPt \ @@ -274,6 +297,8 @@ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\ *pEtryPoint = onSelectReadyWrite;\ } else if(!strcmp((char*) name, "needUDPSocket")) {\ *pEtryPoint = needUDPSocket;\ + } else if(!strcmp((char*) name, "tryResume")) {\ + *pEtryPoint = tryResume;\ } /* modInit() @@ -224,6 +224,10 @@ rsRetVal doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)()) moduleDestruct(pNew); return iRet; } + if((iRet = (*pNew->modQueryEtryPt)((uchar*)"tryResume", &pNew->tryResume)) != RS_RET_OK) { + moduleDestruct(pNew); + return iRet; + } if((iRet = (*pNew->modQueryEtryPt)((uchar*)"freeInstance", &pNew->freeInstance)) != RS_RET_OK) { moduleDestruct(pNew); return iRet; @@ -61,6 +61,7 @@ typedef struct moduleInfo { rsRetVal (*onSelectReadyWrite)(void*);/* called when fd is writeable after select() */ rsRetVal (*needUDPSocket)(void*);/* called when fd is writeable after select() */ rsRetVal (*dbgPrintInstInfo)(void*);/* called before termination or module unload */ + rsRetVal (*tryResume)(void*);/* called to see if module actin can be resumed now */ rsRetVal (*modExit)(); /* called before termination or module unload */ /* below: parse a configuration line - return if processed * or not. If not, must be parsed to next module. diff --git a/omdiscard.c b/omdiscard.c index 3b4d4a73..b6ba3a2f 100644 --- a/omdiscard.c +++ b/omdiscard.c @@ -62,6 +62,10 @@ CODESTARTisCompatibleWithFeature ENDisCompatibleWithFeature +BEGINtryResume +CODESTARTtryResume +ENDtryResume + BEGINdoAction CODESTARTdoAction iRet = RS_RET_DISCARDMSG; @@ -622,6 +622,10 @@ CODESTARTgetWriteFDForSelect ENDgetWriteFDForSelect +BEGINtryResume +CODESTARTtryResume +ENDtryResume + BEGINdoAction CODESTARTdoAction dprintf(" (%s)\n", pData->f_fname); @@ -56,6 +56,23 @@ #include "tcpsyslog.h" #include "module-template.h" +#ifdef SYSLOG_INET +#define INET_SUSPEND_TIME 60 /* equal to 1 minute + * rgerhards, 2005-07-26: This was 3 minutes. As the + * same timer is used for tcp based syslog, we have + * reduced it. However, it might actually be worth + * thinking about a buffered tcp sender, which would be + * a much better alternative. When that happens, this + * time here can be re-adjusted to 3 minutes (or, + * even better, made configurable). + */ +#define INET_RETRY_MAX 30 /* maximum of retries for gethostbyname() */ + /* was 10, changed to 30 because we reduced INET_SUSPEND_TIME by one third. So + * this "fixes" some of implications of it (see comment on INET_SUSPEND_TIME). + * rgerhards, 2005-07-26 + */ +#endif + /* * This table contains plain text for h_errno errors used by the * net subsystem. @@ -525,6 +542,10 @@ static char *getFwdSyslogPt(instanceData *pData) } +BEGINtryResume +CODESTARTtryResume +ENDtryResume + BEGINdoAction char *psz; /* temporary buffering */ register unsigned l; @@ -319,6 +319,10 @@ rsRetVal writeMySQL(uchar *psz, instanceData *pData) } +BEGINtryResume +CODESTARTtryResume +ENDtryResume + BEGINdoAction CODESTARTdoAction dprintf("\n"); @@ -75,6 +75,10 @@ CODESTARTdbgPrintInstInfo ENDdbgPrintInstInfo +BEGINtryResume +CODESTARTtryResume +ENDtryResume + BEGINdoAction CODESTARTdoAction /* TODO: using pData->progName is not clean from the point of @@ -245,6 +245,10 @@ static rsRetVal wallmsg(uchar* pMsg, instanceData *pData) } +BEGINtryResume +CODESTARTtryResume +ENDtryResume + BEGINdoAction CODESTARTdoAction dprintf("\n"); @@ -557,6 +557,7 @@ extern int errno; struct action_s { time_t f_time; /* time this was last written */ short bEnabled; /* is the related action enabled (1) or disabled (0)? */ + short bSuspended; /* is the related action temporarily suspended? */ struct moduleInfo *pMod;/* pointer to output module handling this selector */ void *pModData; /* pointer to module data - contents is module-specific */ int f_ReduceRepeated;/* reduce repeated lines 0 - no, 1 - yes */ @@ -3330,10 +3331,18 @@ rsRetVal fprintlog(action_t *pAction) goto finalize_it; } } - iRet = pAction->pMod->mod.om.doAction(pAction->ppMsgs, pAction->f_pMsg->msgFlags, pAction->pModData); /* call configured action */ + /* call configured action */ + iRet = pAction->pMod->mod.om.doAction(pAction->ppMsgs, pAction->f_pMsg->msgFlags, pAction->pModData); - if(iRet == RS_RET_DISABLE_ACTION) + if(iRet == RS_RET_DISABLE_ACTION) { + dprintf("Action requested to be disabled, done that.\n"); pAction->bEnabled = 0; /* that's it... */ + } + + if(iRet == RS_RET_SUSPENDED) { + dprintf("Action requested to be suspended, done that.\n"); + pAction->bSuspended = 1; /* message process, so we start a new cycle */ + } if(iRet == RS_RET_OK) pAction->f_prevcount = 0; /* message process, so we start a new cycle */ @@ -41,23 +41,6 @@ #define MAXLINE 2048 /* maximum line length */ -#ifdef SYSLOG_INET -#define INET_SUSPEND_TIME 60 /* equal to 1 minute - * rgerhards, 2005-07-26: This was 3 minutes. As the - * same timer is used for tcp based syslog, we have - * reduced it. However, it might actually be worth - * thinking about a buffered tcp sender, which would be - * a much better alternative. When that happens, this - * time here can be re-adjusted to 3 minutes (or, - * even better, made configurable). - */ -#define INET_RETRY_MAX 30 /* maximum of retries for gethostbyname() */ - /* was 10, changed to 30 because we reduced INET_SUSPEND_TIME by one third. So - * this "fixes" some of implications of it (see comment on INET_SUSPEND_TIME). - * rgerhards, 2005-07-26 - */ -#endif - /* Flags to logmsg(). */ #define INTERNAL_MSG 0x001 /* msg generated by logmsgInternal() --> special handling */ |