diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2012-11-03 17:07:22 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-11-03 17:07:22 +0100 |
commit | 5a643669221363a49fb36cfb2acc64dc29b53a14 (patch) | |
tree | fefaea4fa17ed1b26a76a857397a3a3bc7adae27 | |
parent | c28d92259b27eebca3892b9ad18d467691e5aacc (diff) | |
download | rsyslog-5a643669221363a49fb36cfb2acc64dc29b53a14.tar.gz rsyslog-5a643669221363a49fb36cfb2acc64dc29b53a14.tar.bz2 rsyslog-5a643669221363a49fb36cfb2acc64dc29b53a14.zip |
queue: remove time() calls from msg deserialization
-rw-r--r-- | runtime/msg.c | 13 | ||||
-rw-r--r-- | runtime/msg.h | 1 | ||||
-rw-r--r-- | runtime/obj.h | 1 | ||||
-rw-r--r-- | runtime/queue.c | 20 |
4 files changed, 30 insertions, 5 deletions
diff --git a/runtime/msg.c b/runtime/msg.c index b34adca3..dca49a6d 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -814,6 +814,19 @@ finalize_it: } +/* Special msg constructor, to be used when an object is deserialized. + * we do only the base init as we know the properties will be set in + * any case by the deserializer. We still do the "inexpensive" inits + * just to be on the safe side. The whole process needs to be + * refactored together with the msg serialization subsystem. + */ +rsRetVal +msgConstructForDeserializer(msg_t **ppThis) +{ + return msgBaseConstruct(ppThis); +} + + /* some free handlers for (slightly) complicated cases... All of them may be called * with an empty element. */ diff --git a/runtime/msg.h b/runtime/msg.h index 061970aa..950de559 100644 --- a/runtime/msg.h +++ b/runtime/msg.h @@ -147,6 +147,7 @@ struct msg { PROTOTYPEObjClassInit(msg); rsRetVal msgConstruct(msg_t **ppThis); rsRetVal msgConstructWithTime(msg_t **ppThis, struct syslogTime *stTime, time_t ttGenTime); +rsRetVal msgConstructForDeserializer(msg_t **ppThis); rsRetVal msgConstructFinalizer(msg_t *pThis); rsRetVal msgDestruct(msg_t **ppM); rsRetVal MsgSetProperty(msg_t *pThis, var_t *pProp); diff --git a/runtime/obj.h b/runtime/obj.h index dbc2f69b..a93befa3 100644 --- a/runtime/obj.h +++ b/runtime/obj.h @@ -83,7 +83,6 @@ ((obj_t*) (pThis))->pObjInfo = pObjInfoOBJ; \ ((obj_t*) (pThis))->pszName = NULL #endif -#define objDestruct(pThis) (((obj_t*) (pThis))->pObjInfo->objMethods[objMethod_DESTRUCT])(&pThis) #define objSerialize(pThis) (((obj_t*) (pThis))->pObjInfo->objMethods[objMethod_SERIALIZE]) #define OBJSetMethodHandler(methodID, pHdlr) \ diff --git a/runtime/queue.c b/runtime/queue.c index c42b18ad..ed486037 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -918,22 +918,34 @@ finalize_it: static rsRetVal qDeqDisk(qqueue_t *pThis, msg_t **ppMsg) { DEFiRet; - iRet = objDeserializeWithMethods(ppMsg, (uchar*) "msg", pThis->tVars.disk.pReadDeq, NULL, NULL, msgConstruct, msgConstructFinalizer, MsgSetProperty); + iRet = objDeserializeWithMethods(ppMsg, (uchar*) "msg", pThis->tVars.disk.pReadDeq, NULL, + NULL, msgConstructForDeserializer, msgConstructFinalizer, MsgSetProperty); RETiRet; } +/* the following function is a dummy to be used for qDelDisk, which (currently) must + * provide constructors & others even though it does not really need the object. So + * instead of using the real ones, we use the dummy here. That at least saves some time. + * Of course, in the longer term the whole process should be refactored. + * rgerhards, 2012-11-03 + */ +static rsRetVal +qDelDiskCallbackDummy(void) +{ + return RS_RET_OK; +} static rsRetVal qDelDisk(qqueue_t *pThis) { - obj_t *pDummyObj; /* we need to deserialize it... */ + obj_t *pDummyObj; /* another dummy, nothing is created */ DEFiRet; int64 offsIn; int64 offsOut; CHKiRet(strm.GetCurrOffset(pThis->tVars.disk.pReadDel, &offsIn)); - CHKiRet(objDeserializeWithMethods(&pDummyObj, (uchar*) "msg", pThis->tVars.disk.pReadDel, NULL, NULL, msgConstruct, msgConstructFinalizer, MsgSetProperty)); - objDestruct(pDummyObj); + CHKiRet(objDeserializeWithMethods(&pDummyObj, (uchar*) "msg", pThis->tVars.disk.pReadDel, + NULL, NULL, qDelDiskCallbackDummy, qDelDiskCallbackDummy, qDelDiskCallbackDummy)); CHKiRet(strm.GetCurrOffset(pThis->tVars.disk.pReadDel, &offsOut)); /* This time it is a bit tricky: we free disk space only upon file deletion. So we need |