diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-04 16:23:37 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-04 16:23:37 +0000 |
commit | eb9f97ee2d34f00ca823ebead26e133e4b9a8495 (patch) | |
tree | ed1ed4bf41246d80c4347336eaa2b250ae5c6eed | |
parent | faf8e5a3849621acfbd0a0887f2e924a40cb029a (diff) | |
download | rsyslog-eb9f97ee2d34f00ca823ebead26e133e4b9a8495.tar.gz rsyslog-eb9f97ee2d34f00ca823ebead26e133e4b9a8495.tar.xz rsyslog-eb9f97ee2d34f00ca823ebead26e133e4b9a8495.zip |
removed serialization pointer from queue; used new base class instead
-rw-r--r-- | msg.c | 3 | ||||
-rw-r--r-- | obj.h | 5 | ||||
-rw-r--r-- | queue.c | 12 | ||||
-rw-r--r-- | queue.h | 12 | ||||
-rw-r--r-- | syslogd.c | 2 |
5 files changed, 13 insertions, 21 deletions
@@ -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 /* @@ -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) \ @@ -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) { @@ -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 */ @@ -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); |