summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-07-25 16:50:12 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-07-25 16:50:12 +0000
commitd0a93ad442331d12ee474ee859ee4fef5474b98f (patch)
tree760285102bc407030c5161f841a0058601af08c6
parentedbbf96be75d5e3ada30b08d6bf7aea7881248f5 (diff)
downloadrsyslog-d0a93ad442331d12ee474ee859ee4fef5474b98f.tar.gz
rsyslog-d0a93ad442331d12ee474ee859ee4fef5474b98f.tar.xz
rsyslog-d0a93ad442331d12ee474ee859ee4fef5474b98f.zip
introduced getWriteFDForSelect() module API
-rw-r--r--module-template.h23
-rw-r--r--modules.c4
-rw-r--r--modules.h1
-rw-r--r--omdiscard.c5
-rw-r--r--omfile.c5
-rw-r--r--omfwd.c11
-rw-r--r--ommysql.c5
-rw-r--r--omshell.c5
-rw-r--r--omusrmsg.c5
-rw-r--r--rsyslog.h1
-rw-r--r--syslogd.c11
11 files changed, 70 insertions, 6 deletions
diff --git a/module-template.h b/module-template.h
index 8842f7e4..3a8b9129 100644
--- a/module-template.h
+++ b/module-template.h
@@ -120,6 +120,27 @@ static rsRetVal dbgPrintInstInfo(selector_t *f, void *pModData)\
}
+
+/* getWriteFDForSelect()
+ * Extra comments:
+ * Print debug information about this instance.
+ */
+#define BEGINgetWriteFDForSelect \
+static rsRetVal getWriteFDForSelect(selector_t *f, void *pModData, short *fd)\
+{\
+ rsRetVal iRet = RS_RET_NONE;\
+ instanceData *pData = NULL;
+
+#define CODESTARTgetWriteFDForSelect \
+ assert(f != NULL);\
+ assert(fd != NULL);\
+ pData = (instanceData*) pModData;
+
+#define ENDgetWriteFDForSelect \
+ return iRet;\
+}
+
+
/* parseSelectorAct()
* Extra comments:
* try to process a selector action line. Checks if the action
@@ -175,6 +196,8 @@ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\
*pEtryPoint = dbgPrintInstInfo;\
} else if(!strcmp((char*) name, "freeInstance")) {\
*pEtryPoint = freeInstance;\
+ } else if(!strcmp((char*) name, "getWriteFDForSelect")) {\
+ *pEtryPoint = getWriteFDForSelect;\
}
/* modInit()
diff --git a/modules.c b/modules.c
index db79e4ef..445cbb36 100644
--- a/modules.c
+++ b/modules.c
@@ -180,6 +180,10 @@ rsRetVal doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)()), uchar *name)
moduleDestruct(pNew);
return iRet;
}
+ if((iRet = (*pNew->modQueryEtryPt)((uchar*)"getWriteFDForSelect", &pNew->getWriteFDForSelect)) != 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 476a7e76..98256ea9 100644
--- a/modules.h
+++ b/modules.h
@@ -55,6 +55,7 @@ typedef struct moduleInfo {
rsRetVal (*modQueryEtryPt)(uchar *name, rsRetVal (**EtryPoint)()); /* query entry point addresses */
rsRetVal (*isCompatibleWithFeature)(syslogFeature);
rsRetVal (*freeInstance)(struct filed*, void*);/* called before termination or module unload */
+ rsRetVal (*getWriteFDForSelect)(struct filed*, void*,short *);/* called before termination or module unload */
rsRetVal (*dbgPrintInstInfo)(struct filed*, void*);/* called before termination or module unload */
rsRetVal (*modExit)(); /* called before termination or module unload */
/* below: parse a configuration line - return if processed
diff --git a/omdiscard.c b/omdiscard.c
index 6b4034ab..03608bd7 100644
--- a/omdiscard.c
+++ b/omdiscard.c
@@ -92,6 +92,11 @@ CODESTARTparseSelectorAct
ENDparseSelectorAct
+BEGINgetWriteFDForSelect
+CODESTARTgetWriteFDForSelect
+ENDgetWriteFDForSelect
+
+
BEGINqueryEtryPt
CODESTARTqueryEtryPt
CODEqueryEtryPt_STD_OMOD_QUERIES
diff --git a/omfile.c b/omfile.c
index 858b8511..6e03697e 100644
--- a/omfile.c
+++ b/omfile.c
@@ -542,6 +542,11 @@ CODESTARTfreeInstance
ENDfreeInstance
+BEGINgetWriteFDForSelect
+CODESTARTgetWriteFDForSelect
+ENDgetWriteFDForSelect
+
+
BEGINdoAction
CODESTARTdoAction
dprintf(" (%s)\n", f->f_un.f_file.f_fname);
diff --git a/omfwd.c b/omfwd.c
index e54a1fad..521d0597 100644
--- a/omfwd.c
+++ b/omfwd.c
@@ -475,6 +475,17 @@ CODESTARTparseSelectorAct
ENDparseSelectorAct
+BEGINgetWriteFDForSelect
+CODESTARTgetWriteFDForSelect
+ if( (f->f_type == F_FORW)
+ && (f->f_un.f_forw.protocol == FORW_TCP)
+ && TCPSendGetStatus(f) == TCP_SEND_CONNECTING) {
+ *fd = f->f_file;
+ iRet = RS_RET_OK;
+ }
+ENDgetWriteFDForSelect
+
+
BEGINqueryEtryPt
CODESTARTqueryEtryPt
CODEqueryEtryPt_STD_OMOD_QUERIES
diff --git a/ommysql.c b/ommysql.c
index 61691cca..877da4f7 100644
--- a/ommysql.c
+++ b/ommysql.c
@@ -79,6 +79,11 @@ CODESTARTdbgPrintInstInfo
ENDdbgPrintInstInfo
+BEGINgetWriteFDForSelect
+CODESTARTgetWriteFDForSelect
+ENDgetWriteFDForSelect
+
+
static rsRetVal reInitMySQL(register selector_t *f);
diff --git a/omshell.c b/omshell.c
index 8fcd14b7..8b87a3fe 100644
--- a/omshell.c
+++ b/omshell.c
@@ -120,6 +120,11 @@ CODESTARTparseSelectorAct
ENDparseSelectorAct
+BEGINgetWriteFDForSelect
+CODESTARTgetWriteFDForSelect
+ENDgetWriteFDForSelect
+
+
BEGINqueryEtryPt
CODESTARTqueryEtryPt
CODEqueryEtryPt_STD_OMOD_QUERIES
diff --git a/omusrmsg.c b/omusrmsg.c
index 0d848eb2..1613bb65 100644
--- a/omusrmsg.c
+++ b/omusrmsg.c
@@ -319,6 +319,11 @@ CODESTARTparseSelectorAct
ENDparseSelectorAct
+BEGINgetWriteFDForSelect
+CODESTARTgetWriteFDForSelect
+ENDgetWriteFDForSelect
+
+
BEGINqueryEtryPt
CODESTARTqueryEtryPt
CODEqueryEtryPt_STD_OMOD_QUERIES
diff --git a/rsyslog.h b/rsyslog.h
index c6776aa4..5b7d8c34 100644
--- a/rsyslog.h
+++ b/rsyslog.h
@@ -48,6 +48,7 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth
RS_RET_PARAM_ERROR = -1000, /**< invalid parameter in call to function */
RS_RET_MISSING_INTERFACE = -1001,/**< interface version mismatch, required missing */
/* return states for config file processing */
+ RS_RET_NONE = -2000, /**< some value is not available - not necessarily an error */
RS_RET_CONFLINE_UNPROCESSED = -2001,/**< config line was not processed, pass to other module */
RS_RET_DISCARDMSG = -2002, /**< discard message (no error state, processing request!) */
RS_RET_INCOMPATIBLE = -2003, /**< function not compatible with requested feature */
diff --git a/syslogd.c b/syslogd.c
index c484c88b..a40930b0 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -5258,14 +5258,13 @@ static void mainloop(void)
* scheduled to be replaced after the liblogging integration.
* rgerhards 2005-07-20
*/
+ short fdMod;
FD_ZERO(&writefds);
for (f = Files; f != NULL ; f = f->f_next) {
- if( (f->f_type == F_FORW)
- && (f->f_un.f_forw.protocol == FORW_TCP)
- && (TCPSendGetStatus(f) == TCP_SEND_CONNECTING)) {
- FD_SET(f->f_file, &writefds);
- if(f->f_file > maxfds)
- maxfds = f->f_file;
+ if(f->pMod->getWriteFDForSelect(f, f->pModData, &fdMod) == RS_RET_OK) {
+ FD_SET(fdMod, &writefds);
+ if(fdMod > maxfds)
+ maxfds = fdMod;
}
}
}