diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2007-12-14 17:15:35 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2007-12-14 17:15:35 +0000 |
commit | 3a209d530568ddfb448d3b55e506022245e394b4 (patch) | |
tree | 9a9e00ae93679d57223a54554e337aefb6f6cd2e | |
parent | 6c0c26dc96544aa5814d00045b3d559c99fc1b2e (diff) | |
download | rsyslog-3a209d530568ddfb448d3b55e506022245e394b4.tar.gz rsyslog-3a209d530568ddfb448d3b55e506022245e394b4.tar.xz rsyslog-3a209d530568ddfb448d3b55e506022245e394b4.zip |
added thread activation
-rw-r--r-- | module-template.h | 5 | ||||
-rw-r--r-- | modules.c | 2 | ||||
-rw-r--r-- | modules.h | 8 | ||||
-rw-r--r-- | syslogd.c | 2 | ||||
-rw-r--r-- | threads.c | 20 | ||||
-rw-r--r-- | threads.h | 1 |
6 files changed, 31 insertions, 7 deletions
diff --git a/module-template.h b/module-template.h index 4bce7f8d..a9535428 100644 --- a/module-template.h +++ b/module-template.h @@ -373,7 +373,10 @@ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\ * differences) is needed. */ #define CODEqueryEtryPt_STD_IMOD_QUERIES \ - CODEqueryEtryPt_STD_MOD_QUERIES + CODEqueryEtryPt_STD_MOD_QUERIES \ + else if(!strcmp((char*) name, "runInput")) {\ + *pEtryPoint = runInput;\ + } /* modInit() * This has an extra parameter, which is the specific name of the modInit @@ -255,6 +255,7 @@ rsRetVal doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)()) /* ... and now the module-specific interfaces */ switch(pNew->eType) { case eMOD_IN: + CHKiRet((*pNew->modQueryEtryPt)((uchar*)"runInput", &pNew->mod.im.runInput)); break; case eMOD_OUT: CHKiRet((*pNew->modQueryEtryPt)((uchar*)"doAction", &pNew->mod.om.doAction)); @@ -293,6 +294,7 @@ finalize_it: /* Print loaded modules. This is more or less a * debug or test aid, but anyhow I think it's worth it... * This only works if the dbgprintf() subsystem is initialized. + * TODO: update for new input modules! */ void modPrintList(void) { @@ -73,14 +73,10 @@ typedef struct moduleInfo { * can allocate instance memory in this call. */ rsRetVal (*createInstance)(); - /* input module specific members */ - /* TODO: do a union with members, pass pointer to msg submit function to IM rger, 2007-12-14 */ - rsRetVal (*runInput)(void); /* function to gather input and submit to queue */ + /* TODO: pass pointer to msg submit function to IM rger, 2007-12-14 */ union { struct {/* data for input modules */ - /* input modules come after output modules are finished, I am - * currently not really thinking about them. rgerhards, 2007-07-19 - */ + rsRetVal (*runInput)(void); /* function to gather input and submit to queue */ } im; struct {/* data for output modules */ /* below: perform the configured action @@ -4243,6 +4243,8 @@ startInputModules(void) pMod = modGetNxtType(NULL, eMOD_IN); while(pMod != NULL) { /* activate here */ +dbgprintf("thread creating...\n"); + thrdCreate(pMod->mod.im.runInput); pMod = modGetNxtType(pMod, eMOD_IN); } @@ -101,6 +101,26 @@ rsRetVal thrdTerminate(thrdInfo_t *pThis) } +/* Start a new thread and add it to the list of currently + * executing threads. It is added at the end of the list. + * rgerhards, 2007-12-14 + */ +rsRetVal thrdCreate(void* (*thrdMain)(void*)) +{ + DEFiRet; + thrdInfo_t *pThis; + int i; + + assert(thrdMain != NULL); + + CHKiRet(thrdConstruct(&pThis)); + i = pthread_create(&pThis->thrdID, NULL, thrdMain, NULL); + +finalize_it: + return iRet; +} + + /* initialize the thread-support subsystem * must be called once at the start of the program */ @@ -50,6 +50,7 @@ typedef struct { /* prototypes */ rsRetVal thrdTerminate(thrdInfo_t *pThis); +rsRetVal thrdCreate(void* (*thrdMain)(void*)); msgQueue *queueInit (void); void queueDelete (msgQueue *q); void queueAdd (msgQueue *q, void* in); |