summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-12-14 17:15:35 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-12-14 17:15:35 +0000
commit3a209d530568ddfb448d3b55e506022245e394b4 (patch)
tree9a9e00ae93679d57223a54554e337aefb6f6cd2e
parent6c0c26dc96544aa5814d00045b3d559c99fc1b2e (diff)
downloadrsyslog-3a209d530568ddfb448d3b55e506022245e394b4.tar.gz
rsyslog-3a209d530568ddfb448d3b55e506022245e394b4.tar.xz
rsyslog-3a209d530568ddfb448d3b55e506022245e394b4.zip
added thread activation
-rw-r--r--module-template.h5
-rw-r--r--modules.c2
-rw-r--r--modules.h8
-rw-r--r--syslogd.c2
-rw-r--r--threads.c20
-rw-r--r--threads.h1
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
diff --git a/modules.c b/modules.c
index 6869ede6..9a3786f2 100644
--- a/modules.c
+++ b/modules.c
@@ -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)
{
diff --git a/modules.h b/modules.h
index 914a65fd..9a1a4d41 100644
--- a/modules.h
+++ b/modules.h
@@ -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
diff --git a/syslogd.c b/syslogd.c
index 1da475e5..f93a05c2 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -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);
}
diff --git a/threads.c b/threads.c
index d5168d02..d58a291f 100644
--- a/threads.c
+++ b/threads.c
@@ -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
*/
diff --git a/threads.h b/threads.h
index dd2b17f7..99796313 100644
--- a/threads.h
+++ b/threads.h
@@ -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);