diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2007-07-25 16:50:12 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2007-07-25 16:50:12 +0000 |
commit | d0a93ad442331d12ee474ee859ee4fef5474b98f (patch) | |
tree | 760285102bc407030c5161f841a0058601af08c6 | |
parent | edbbf96be75d5e3ada30b08d6bf7aea7881248f5 (diff) | |
download | rsyslog-d0a93ad442331d12ee474ee859ee4fef5474b98f.tar.gz rsyslog-d0a93ad442331d12ee474ee859ee4fef5474b98f.tar.xz rsyslog-d0a93ad442331d12ee474ee859ee4fef5474b98f.zip |
introduced getWriteFDForSelect() module API
-rw-r--r-- | module-template.h | 23 | ||||
-rw-r--r-- | modules.c | 4 | ||||
-rw-r--r-- | modules.h | 1 | ||||
-rw-r--r-- | omdiscard.c | 5 | ||||
-rw-r--r-- | omfile.c | 5 | ||||
-rw-r--r-- | omfwd.c | 11 | ||||
-rw-r--r-- | ommysql.c | 5 | ||||
-rw-r--r-- | omshell.c | 5 | ||||
-rw-r--r-- | omusrmsg.c | 5 | ||||
-rw-r--r-- | rsyslog.h | 1 | ||||
-rw-r--r-- | syslogd.c | 11 |
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() @@ -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; @@ -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 @@ -542,6 +542,11 @@ CODESTARTfreeInstance ENDfreeInstance +BEGINgetWriteFDForSelect +CODESTARTgetWriteFDForSelect +ENDgetWriteFDForSelect + + BEGINdoAction CODESTARTdoAction dprintf(" (%s)\n", f->f_un.f_file.f_fname); @@ -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 @@ -79,6 +79,11 @@ CODESTARTdbgPrintInstInfo ENDdbgPrintInstInfo +BEGINgetWriteFDForSelect +CODESTARTgetWriteFDForSelect +ENDgetWriteFDForSelect + + static rsRetVal reInitMySQL(register selector_t *f); @@ -120,6 +120,11 @@ CODESTARTparseSelectorAct ENDparseSelectorAct +BEGINgetWriteFDForSelect +CODESTARTgetWriteFDForSelect +ENDgetWriteFDForSelect + + BEGINqueryEtryPt CODESTARTqueryEtryPt CODEqueryEtryPt_STD_OMOD_QUERIES @@ -319,6 +319,11 @@ CODESTARTparseSelectorAct ENDparseSelectorAct +BEGINgetWriteFDForSelect +CODESTARTgetWriteFDForSelect +ENDgetWriteFDForSelect + + BEGINqueryEtryPt CODESTARTqueryEtryPt CODEqueryEtryPt_STD_OMOD_QUERIES @@ -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 */ @@ -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; } } } |