summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--msg.c3
-rw-r--r--obj.h5
-rw-r--r--queue.c12
-rw-r--r--queue.h12
-rw-r--r--syslogd.c2
5 files changed, 13 insertions, 21 deletions
diff --git a/msg.c b/msg.c
index bb913e96..ddf6004e 100644
--- a/msg.c
+++ b/msg.c
@@ -290,6 +290,7 @@ rsRetVal MsgSerialize(uchar **ppOutBuf, size_t *pLenBuf, void *pUsr)
msg_t* pThis = pUsr;
rsCStrObj *pCStr;
+dbgprintf("MsgSerialize in\n");
assert(ppOutBuf != NULL);
assert(pLenBuf != NULL);
assert(pThis != NULL);
@@ -1933,6 +1934,8 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
*/
BEGINObjClassInit(Msg)
OBJSetMethodHandler(objMethod_SERIALIZE, MsgSerialize);
+printf("MSgSerialize pointer: %lx\n", (unsigned long) MsgSerialize);
+printf("Msg objInfo: %lx\n", pObjInfoOBJ );
ENDObjClassInit
/*
diff --git a/obj.h b/obj.h
index 70cc021c..5f0921f3 100644
--- a/obj.h
+++ b/obj.h
@@ -44,7 +44,7 @@ typedef enum { /* IDs of base methods supported by all objects - used for jump t
typedef struct objInfo_s {
objID_t objID;
uchar *pszName;
- rsRetVal (*objMethods[OBJ_NUM_METHODS])(void *pThis);
+ rsRetVal (*objMethods[OBJ_NUM_METHODS])();
} objInfo_t;
typedef struct obj { /* the dummy struct that each derived class can be casted to */
@@ -57,7 +57,8 @@ typedef struct obj { /* the dummy struct that each derived class can be casted t
#define BEGINobjInstance objInfo_t *pObjInfo
/* must be called in Constructor: */
#define objConstructSetObjInfo(pThis) ((obj_t*) (pThis))->pObjInfo = pObjInfoOBJ;
-#define objDestruct(pThis) ((objInfo_t*) (pThis)->objMethods[objMethod_DESTRUCT])
+#define objDestruct(pThis) (((obj_t*) (pThis))->pObjInfo->objMethods[objMethod_DESTRUCT])
+#define objSerialize(pThis) (((obj_t*) (pThis))->pObjInfo->objMethods[objMethod_SERIALIZE])
/* class initializer */
#define PROTOTYPEObjClassInit(objName) rsRetVal objName##ClassInit(void)
#define BEGINObjClassInit(objName) \
diff --git a/queue.c b/queue.c
index c972af6c..8eb98d72 100644
--- a/queue.c
+++ b/queue.c
@@ -202,7 +202,7 @@ rsRetVal qConstructDisk(queue_t *pThis)
CHKiRet(genFileName(&pszFile, pThis->tVars.disk.pszSpoolDir, pThis->tVars.disk.lenSpoolDir,
(uchar*) "mainq", 5, 1, (uchar*) "qf", 2));
- dbgprintf("Queue 0x%lx: opening file '%s'\n", pThis, pszFile);
+ dbgprintf("Queue 0x%lx: opening file '%s'\n", (unsigned long) pThis, pszFile);
pThis->tVars.disk.fd = open((char*)pszFile, O_RDWR|O_CREAT, 0600);
dbgprintf("opened file %d\n", pThis->tVars.disk.fd);
@@ -235,7 +235,8 @@ rsRetVal qAddDisk(queue_t *pThis, void* pUsr)
assert(pThis != NULL);
dbgprintf("writing to file %d\n", pThis->tVars.disk.fd);
- CHKiRet(pThis->serializer(pBuf, &lenBuf, pUsr)); // TODO: hier weiter machen!
+dbgprintf("objInfo: %lx\n", (unsigned long)pUsr);
+ CHKiRet((objSerialize(pUsr))(pBuf, &lenBuf, pUsr)); // TODO: hier weiter machen!
i = write(pThis->tVars.disk.fd, "entry\n", 6);
dbgprintf("write wrote %d bytes, errno: %d, err %s\n", i, errno, strerror(errno));
@@ -357,10 +358,7 @@ queueWorker(void *arg)
}
/* Constructor for the queue object */
-rsRetVal queueConstruct(queue_t **ppThis, queueType_t qType, int iMaxQueueSize, rsRetVal (*pConsumer)(void*),
- rsRetVal (*serializer)(uchar **ppOutBuf, size_t *lenBuf, void *pUsr),
- rsRetVal (*deSerializer)(void *ppUsr, uchar *ppBuf, size_t lenBuf)
- )
+rsRetVal queueConstruct(queue_t **ppThis, queueType_t qType, int iMaxQueueSize, rsRetVal (*pConsumer)(void*))
{
DEFiRet;
queue_t *pThis;
@@ -384,8 +382,6 @@ rsRetVal queueConstruct(queue_t **ppThis, queueType_t qType, int iMaxQueueSize,
pThis->notEmpty = (pthread_cond_t *) malloc (sizeof (pthread_cond_t));
pthread_cond_init (pThis->notEmpty, NULL);
pThis->qType = qType;
- pThis->serializer = serializer;
- pThis->deSerializer = deSerializer;
/* set type-specific handlers */
switch(qType) {
diff --git a/queue.h b/queue.h
index 8bf308ba..b62a4804 100644
--- a/queue.h
+++ b/queue.h
@@ -24,6 +24,7 @@
#define QUEUE_H_INCLUDED
#include <pthread.h>
+#include "obj.h"
/* queue types */
typedef enum {
@@ -51,12 +52,6 @@ typedef struct queue_s {
rsRetVal (*qDestruct)(struct queue_s *pThis);
rsRetVal (*qAdd)(struct queue_s *pThis, void *pUsr);
rsRetVal (*qDel)(struct queue_s *pThis, void **ppUsr);
- /* the following two are currently only required for disk queuing, but
- * we keep them global because we otherwise needed to change the interface
- * too much.
- */
- rsRetVal (*serializer)(uchar **ppOutBuf, size_t *lenBuf, void *pUsr);
- rsRetVal (*deSerializer)(void *ppUsr, uchar *ppBuf, size_t lenBuf);
/* end type-specific handler */
/* synchronization variables */
pthread_mutex_t *mut;
@@ -88,9 +83,6 @@ typedef struct queue_s {
/* prototypes */
rsRetVal queueDestruct(queue_t *pThis);
rsRetVal queueEnqObj(queue_t *pThis, void *pUsr);
-rsRetVal queueConstruct(queue_t **ppThis, queueType_t qType, int iMaxQueueSize, rsRetVal (*pConsumer)(void*),
- rsRetVal (*serializer)(uchar **ppOutBuf, size_t *lenBuf, void *pUsr),
- rsRetVal (*deSerializer)(void *ppUsr, uchar *ppBuf, size_t lenBuf)
- );
+rsRetVal queueConstruct(queue_t **ppThis, queueType_t qType, int iMaxQueueSize, rsRetVal (*pConsumer)(void*));
#endif /* #ifndef QUEUE_H_INCLUDED */
diff --git a/syslogd.c b/syslogd.c
index 47ea2265..af4ec5bf 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -3353,7 +3353,7 @@ init(void)
}
/* create message queue */
- CHKiRet_Hdlr(queueConstruct(&pMsgQueue, MainMsgQueType, iMainMsgQueueSize, msgConsumer, MsgSerialize, NULL)) {
+ CHKiRet_Hdlr(queueConstruct(&pMsgQueue, MainMsgQueType, iMainMsgQueueSize, msgConsumer)) {
/* no queue is fatal, we need to give up in that case... */
fprintf(stderr, "fatal error %d: could not create message queue - rsyslogd can not run!\n", iRet);
exit(1);