summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module-template.h25
-rw-r--r--modules.c4
-rw-r--r--modules.h1
-rw-r--r--omdiscard.c4
-rw-r--r--omfile.c4
-rw-r--r--omfwd.c21
-rw-r--r--ommysql.c4
-rw-r--r--omshell.c4
-rw-r--r--omusrmsg.c4
-rw-r--r--syslogd.c13
-rw-r--r--syslogd.h17
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()
diff --git a/modules.c b/modules.c
index 32bec07c..ec816c43 100644
--- a/modules.c
+++ b/modules.c
@@ -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;
diff --git a/modules.h b/modules.h
index 6072cfd2..c05026ed 100644
--- a/modules.h
+++ b/modules.h
@@ -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;
diff --git a/omfile.c b/omfile.c
index 493aba89..ce42997c 100644
--- a/omfile.c
+++ b/omfile.c
@@ -622,6 +622,10 @@ CODESTARTgetWriteFDForSelect
ENDgetWriteFDForSelect
+BEGINtryResume
+CODESTARTtryResume
+ENDtryResume
+
BEGINdoAction
CODESTARTdoAction
dprintf(" (%s)\n", pData->f_fname);
diff --git a/omfwd.c b/omfwd.c
index 0a7fa0c8..a3770cad 100644
--- a/omfwd.c
+++ b/omfwd.c
@@ -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;
diff --git a/ommysql.c b/ommysql.c
index 7f340026..af562b43 100644
--- a/ommysql.c
+++ b/ommysql.c
@@ -319,6 +319,10 @@ rsRetVal writeMySQL(uchar *psz, instanceData *pData)
}
+BEGINtryResume
+CODESTARTtryResume
+ENDtryResume
+
BEGINdoAction
CODESTARTdoAction
dprintf("\n");
diff --git a/omshell.c b/omshell.c
index 961078d4..f2826a75 100644
--- a/omshell.c
+++ b/omshell.c
@@ -75,6 +75,10 @@ CODESTARTdbgPrintInstInfo
ENDdbgPrintInstInfo
+BEGINtryResume
+CODESTARTtryResume
+ENDtryResume
+
BEGINdoAction
CODESTARTdoAction
/* TODO: using pData->progName is not clean from the point of
diff --git a/omusrmsg.c b/omusrmsg.c
index a3120280..7fe56dde 100644
--- a/omusrmsg.c
+++ b/omusrmsg.c
@@ -245,6 +245,10 @@ static rsRetVal wallmsg(uchar* pMsg, instanceData *pData)
}
+BEGINtryResume
+CODESTARTtryResume
+ENDtryResume
+
BEGINdoAction
CODESTARTdoAction
dprintf("\n");
diff --git a/syslogd.c b/syslogd.c
index 34c4f2c2..a23553c0 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -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 */
diff --git a/syslogd.h b/syslogd.h
index 697ad411..3869ecbf 100644
--- a/syslogd.h
+++ b/syslogd.h
@@ -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 */