summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-01-30 08:02:42 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-01-30 08:02:42 +0000
commit4984c1ba6c84a3ae91f9afd4da2ea718c98c97a7 (patch)
tree39972db40d9d0f642879a663aadcad996a510e50
parentef44f5c9ba319e2813e5ea23b2699b73b63cdcbb (diff)
downloadrsyslog-4984c1ba6c84a3ae91f9afd4da2ea718c98c97a7.tar.gz
rsyslog-4984c1ba6c84a3ae91f9afd4da2ea718c98c97a7.tar.xz
rsyslog-4984c1ba6c84a3ae91f9afd4da2ea718c98c97a7.zip
- renamed Msg object to usual all-lowercase object name (else we ran into
troubles with the framework, also it was somewhat ugly...) - fixed a memory leak in object destruction (was recently introduced by object naming, not present in any released version)
-rw-r--r--action.c12
-rw-r--r--doc/Makefile.am1
-rw-r--r--iminternal.c2
-rw-r--r--msg.c146
-rw-r--r--msg.h6
-rw-r--r--obj-types.h52
-rw-r--r--obj.c15
-rw-r--r--obj.h1
-rw-r--r--plugins/imklog/imklog.c2
-rw-r--r--queue.c30
-rw-r--r--stream.c19
-rw-r--r--syslogd.c12
-rw-r--r--wti.c26
-rw-r--r--wtp.c27
14 files changed, 166 insertions, 185 deletions
diff --git a/action.c b/action.c
index c02bfa42..d60e2d77 100644
--- a/action.c
+++ b/action.c
@@ -125,7 +125,7 @@ rsRetVal actionDestruct(action_t *pThis)
pThis->pMod->freeInstance(pThis->pModData);
if(pThis->f_pMsg != NULL)
- MsgDestruct(&pThis->f_pMsg);
+ msgDestruct(&pThis->f_pMsg);
SYNC_OBJ_TOOL_EXIT(pThis);
if(pThis->ppTpl != NULL)
@@ -394,7 +394,7 @@ finalize_it:
pAction->ppMsgs[i] = NULL;
}
}
- MsgDestruct(&pMsg); /* we are now finished with the message */
+ msgDestruct(&pMsg); /* we are now finished with the message */
RETiRet;
}
@@ -505,7 +505,7 @@ finalize_it:
* message object will be discarded by our callers, so this is nothing
* of our business. rgerhards, 2007-07-10
*/
- MsgDestruct(&pAction->f_pMsg);
+ msgDestruct(&pAction->f_pMsg);
pAction->f_pMsg = pMsgSave; /* restore it */
}
@@ -522,7 +522,7 @@ actionCallAction(action_t *pAction, msg_t *pMsg)
DEFiRet;
int iCancelStateSave;
- ISOBJ_TYPE_assert(pMsg, Msg);
+ ISOBJ_TYPE_assert(pMsg, msg);
ASSERT(pAction != NULL);
/* Make sure nodbody else modifies/uses this action object. Right now, this
@@ -566,7 +566,7 @@ actionCallAction(action_t *pAction, msg_t *pMsg)
pAction->f_prevcount, time(NULL) - pAction->f_time,
repeatinterval[pAction->f_repeatcount]);
/* use current message, so we have the new timestamp (means we need to discard previous one) */
- MsgDestruct(&pAction->f_pMsg);
+ msgDestruct(&pAction->f_pMsg);
pAction->f_pMsg = MsgAddRef(pMsg);
/* If domark would have logged this by now, flush it now (so we don't hold
* isolated messages), but back off so we'll flush less often in the future.
@@ -586,7 +586,7 @@ actionCallAction(action_t *pAction, msg_t *pMsg)
/* we do not care about iRet above - I think it's right but if we have
* some troubles, you know where to look at ;) -- rgerhards, 2007-08-01
*/
- MsgDestruct(&pAction->f_pMsg);
+ msgDestruct(&pAction->f_pMsg);
}
pAction->f_pMsg = MsgAddRef(pMsg);
/* call the output driver */
diff --git a/doc/Makefile.am b/doc/Makefile.am
index ab192eec..07ba61d9 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -10,6 +10,7 @@ html_files = \
man_rsyslogd.html \
modules.html \
property_replacer.html \
+ rsyslog_ng_comparison.html \
rsyslog_conf.html \
rsyslog_mysql.html \
rsyslog_packages.html \
diff --git a/iminternal.c b/iminternal.c
index fb70d062..60460a99 100644
--- a/iminternal.c
+++ b/iminternal.c
@@ -49,7 +49,7 @@ static rsRetVal iminternalDestruct(iminternal_t *pThis)
assert(pThis != NULL);
if(pThis->pMsg != NULL)
- MsgDestruct(&pThis->pMsg);
+ msgDestruct(&pThis->pMsg);
free(pThis);
diff --git a/msg.c b/msg.c
index cc81c109..11b87b92 100644
--- a/msg.c
+++ b/msg.c
@@ -202,9 +202,9 @@ rsRetVal MsgEnableThreadSafety(void)
/* "Constructor" for a msg "object". Returns a pointer to
* the new object or NULL if no such object could be allocated.
* An object constructed via this function should only be destroyed
- * via "MsgDestruct()".
+ * via "msgDestruct()".
*/
-rsRetVal MsgConstruct(msg_t **ppThis)
+rsRetVal msgConstruct(msg_t **ppThis)
{
DEFiRet;
msg_t *pM;
@@ -220,7 +220,7 @@ rsRetVal MsgConstruct(msg_t **ppThis)
getCurrTime(&(pM->tRcvdAt));
objConstructSetObjInfo(pM);
- /* DEV debugging only! dbgprintf("MsgConstruct\t0x%x, ref 1\n", (int)pM);*/
+ /* DEV debugging only! dbgprintf("msgConstruct\t0x%x, ref 1\n", (int)pM);*/
*ppThis = pM;
@@ -229,75 +229,65 @@ finalize_it:
}
-/* Destructor for a msg "object". Must be called to dispose
- * of a msg object.
- */
-rsRetVal MsgDestruct(msg_t **ppM)
-{
- msg_t *pM;
-
- assert(ppM != NULL);
- pM = *ppM;
- assert(pM != NULL);
- /* DEV Debugging only ! dbgprintf("MsgDestruct\t0x%lx, Ref now: %d\n", (unsigned long)pM, pM->iRefCount - 1); */
- if(--pM->iRefCount == 0)
+BEGINobjDestruct(msg) /* be sure to specify the object type also in END and CODESTART macros! */
+CODESTARTobjDestruct(msg)
+ /* DEV Debugging only ! dbgprintf("msgDestruct\t0x%lx, Ref now: %d\n", (unsigned long)pM, pM->iRefCount - 1); */
+ if(--pThis->iRefCount == 0)
{
- /* DEV Debugging Only! dbgprintf("MsgDestruct\t0x%lx, RefCount now 0, doing DESTROY\n", (unsigned long)pM); */
- if(pM->pszUxTradMsg != NULL)
- free(pM->pszUxTradMsg);
- if(pM->pszRawMsg != NULL)
- free(pM->pszRawMsg);
- if(pM->pszTAG != NULL)
- free(pM->pszTAG);
- if(pM->pszHOSTNAME != NULL)
- free(pM->pszHOSTNAME);
- if(pM->pszRcvFrom != NULL)
- free(pM->pszRcvFrom);
- if(pM->pszMSG != NULL)
- free(pM->pszMSG);
- if(pM->pszFacility != NULL)
- free(pM->pszFacility);
- if(pM->pszFacilityStr != NULL)
- free(pM->pszFacilityStr);
- if(pM->pszSeverity != NULL)
- free(pM->pszSeverity);
- if(pM->pszSeverityStr != NULL)
- free(pM->pszSeverityStr);
- if(pM->pszRcvdAt3164 != NULL)
- free(pM->pszRcvdAt3164);
- if(pM->pszRcvdAt3339 != NULL)
- free(pM->pszRcvdAt3339);
- if(pM->pszRcvdAt_MySQL != NULL)
- free(pM->pszRcvdAt_MySQL);
- if(pM->pszRcvdAt_PgSQL != NULL)
- free(pM->pszRcvdAt_PgSQL);
- if(pM->pszTIMESTAMP3164 != NULL)
- free(pM->pszTIMESTAMP3164);
- if(pM->pszTIMESTAMP3339 != NULL)
- free(pM->pszTIMESTAMP3339);
- if(pM->pszTIMESTAMP_MySQL != NULL)
- free(pM->pszTIMESTAMP_MySQL);
- if(pM->pszTIMESTAMP_PgSQL != NULL)
- free(pM->pszTIMESTAMP_PgSQL);
- if(pM->pszPRI != NULL)
- free(pM->pszPRI);
- if(pM->pCSProgName != NULL)
- rsCStrDestruct(pM->pCSProgName);
- if(pM->pCSStrucData != NULL)
- rsCStrDestruct(pM->pCSStrucData);
- if(pM->pCSAPPNAME != NULL)
- rsCStrDestruct(pM->pCSAPPNAME);
- if(pM->pCSPROCID != NULL)
- rsCStrDestruct(pM->pCSPROCID);
- if(pM->pCSMSGID != NULL)
- rsCStrDestruct(pM->pCSMSGID);
- funcDeleteMutex(pM);
- free(pM);
- *ppM = NULL;
+ /* DEV Debugging Only! dbgprintf("msgDestruct\t0x%lx, RefCount now 0, doing DESTROY\n", (unsigned long)pThis); */
+ if(pThis->pszUxTradMsg != NULL)
+ free(pThis->pszUxTradMsg);
+ if(pThis->pszRawMsg != NULL)
+ free(pThis->pszRawMsg);
+ if(pThis->pszTAG != NULL)
+ free(pThis->pszTAG);
+ if(pThis->pszHOSTNAME != NULL)
+ free(pThis->pszHOSTNAME);
+ if(pThis->pszRcvFrom != NULL)
+ free(pThis->pszRcvFrom);
+ if(pThis->pszMSG != NULL)
+ free(pThis->pszMSG);
+ if(pThis->pszFacility != NULL)
+ free(pThis->pszFacility);
+ if(pThis->pszFacilityStr != NULL)
+ free(pThis->pszFacilityStr);
+ if(pThis->pszSeverity != NULL)
+ free(pThis->pszSeverity);
+ if(pThis->pszSeverityStr != NULL)
+ free(pThis->pszSeverityStr);
+ if(pThis->pszRcvdAt3164 != NULL)
+ free(pThis->pszRcvdAt3164);
+ if(pThis->pszRcvdAt3339 != NULL)
+ free(pThis->pszRcvdAt3339);
+ if(pThis->pszRcvdAt_MySQL != NULL)
+ free(pThis->pszRcvdAt_MySQL);
+ if(pThis->pszRcvdAt_PgSQL != NULL)
+ free(pThis->pszRcvdAt_PgSQL);
+ if(pThis->pszTIMESTAMP3164 != NULL)
+ free(pThis->pszTIMESTAMP3164);
+ if(pThis->pszTIMESTAMP3339 != NULL)
+ free(pThis->pszTIMESTAMP3339);
+ if(pThis->pszTIMESTAMP_MySQL != NULL)
+ free(pThis->pszTIMESTAMP_MySQL);
+ if(pThis->pszTIMESTAMP_PgSQL != NULL)
+ free(pThis->pszTIMESTAMP_PgSQL);
+ if(pThis->pszPRI != NULL)
+ free(pThis->pszPRI);
+ if(pThis->pCSProgName != NULL)
+ rsCStrDestruct(pThis->pCSProgName);
+ if(pThis->pCSStrucData != NULL)
+ rsCStrDestruct(pThis->pCSStrucData);
+ if(pThis->pCSAPPNAME != NULL)
+ rsCStrDestruct(pThis->pCSAPPNAME);
+ if(pThis->pCSPROCID != NULL)
+ rsCStrDestruct(pThis->pCSPROCID);
+ if(pThis->pCSMSGID != NULL)
+ rsCStrDestruct(pThis->pCSMSGID);
+ funcDeleteMutex(pThis);
+ } else {
+ pThis = NULL; /* tell framework not to destructing the object! */
}
-
- return RS_RET_OK;
-}
+ENDobjDestruct(msg)
/* The macros below are used in MsgDup(). I use macros
@@ -307,7 +297,7 @@ rsRetVal MsgDestruct(msg_t **ppM)
#define tmpCOPYSZ(name) \
if(pOld->psz##name != NULL) { \
if((pNew->psz##name = srUtilStrDup(pOld->psz##name, pOld->iLen##name)) == NULL) {\
- MsgDestruct(&pNew);\
+ msgDestruct(&pNew);\
return NULL;\
}\
pNew->iLen##name = pOld->iLen##name;\
@@ -320,7 +310,7 @@ rsRetVal MsgDestruct(msg_t **ppM)
#define tmpCOPYCSTR(name) \
if(pOld->pCS##name != NULL) {\
if(rsCStrConstructFromCStr(&(pNew->pCS##name), pOld->pCS##name) != RS_RET_OK) {\
- MsgDestruct(&pNew);\
+ msgDestruct(&pNew);\
return NULL;\
}\
}
@@ -2095,7 +2085,7 @@ rsRetVal MsgSetProperty(msg_t *pThis, property_t *pProp)
{
DEFiRet;
- ISOBJ_TYPE_assert(pThis, Msg);
+ ISOBJ_TYPE_assert(pThis, msg);
assert(pProp != NULL);
if(isProp("iProtocolVersion")) {
@@ -2142,7 +2132,7 @@ rsRetVal MsgSetProperty(msg_t *pThis, property_t *pProp)
* is done, the object is considered ready for full processing.
* rgerhards, 2008-07-08
*/
-static rsRetVal MsgConstructFinalizer(msg_t *pThis)
+static rsRetVal msgConstructFinalizer(msg_t *pThis)
{
MsgPrepareEnqueue(pThis);
return RS_RET_OK;
@@ -2156,7 +2146,7 @@ static rsRetVal MsgConstructFinalizer(msg_t *pThis)
static rsRetVal
MsgGetSeverity(obj_t *pThis, int *piSeverity)
{
- ISOBJ_TYPE_assert(pThis, Msg);
+ ISOBJ_TYPE_assert(pThis, msg);
assert(piSeverity != NULL);
*piSeverity = ((msg_t*) pThis)->iSeverity;
return RS_RET_OK;
@@ -2167,17 +2157,17 @@ MsgGetSeverity(obj_t *pThis, int *piSeverity)
* before anything else is called inside this class.
* rgerhards, 2008-01-04
*/
-BEGINObjClassInit(Msg, 1)
+BEGINObjClassInit(msg, 1)
OBJSetMethodHandler(objMethod_SERIALIZE, MsgSerialize);
OBJSetMethodHandler(objMethod_SETPROPERTY, MsgSetProperty);
- OBJSetMethodHandler(objMethod_CONSTRUCTION_FINALIZER, MsgConstructFinalizer);
+ OBJSetMethodHandler(objMethod_CONSTRUCTION_FINALIZER, msgConstructFinalizer);
OBJSetMethodHandler(objMethod_GETSEVERITY, MsgGetSeverity);
/* initially, we have no need to lock message objects */
funcLock = MsgLockingDummy;
funcUnlock = MsgLockingDummy;
funcDeleteMutex = MsgLockingDummy;
funcMsgPrepareEnqueue = MsgLockingDummy;
-ENDObjClassInit(Msg)
+ENDObjClassInit(msg)
/*
* vi:set ai:
diff --git a/msg.h b/msg.h
index 842a9349..91e3df89 100644
--- a/msg.h
+++ b/msg.h
@@ -106,10 +106,10 @@ typedef struct msg msg_t; /* new name */
/* function prototypes
*/
-PROTOTYPEObjClassInit(Msg);
+PROTOTYPEObjClassInit(msg);
char* getProgramName(msg_t*);
-rsRetVal MsgConstruct(msg_t **ppThis);
-rsRetVal MsgDestruct(msg_t **ppM);
+rsRetVal msgConstruct(msg_t **ppThis);
+rsRetVal msgDestruct(msg_t **ppM);
msg_t* MsgDup(msg_t* pOld);
msg_t *MsgAddRef(msg_t *pM);
void setProtocolVersion(msg_t *pM, int iNewVersion);
diff --git a/obj-types.h b/obj-types.h
index 030099bb..66dc4143 100644
--- a/obj-types.h
+++ b/obj-types.h
@@ -57,7 +57,7 @@ typedef struct {
/* object Types/IDs */
typedef enum { /* IDs of known object "types/classes" */
OBJNull = 0, /* no valid object (we do not start at zero so we can detect calloc()) */
- OBJMsg = 1,
+ OBJmsg = 1,
OBJstrm = 2,
OBJwtp = 3,
OBJwti = 4,
@@ -168,6 +168,7 @@ finalize_it: \
RETiRet; \
}
+
/* this defines both the constructor and initializer
* rgerhards, 2008-01-10
*/
@@ -185,7 +186,7 @@ finalize_it: \
DEFiRet; \
obj##_t *pThis; \
\
- assert(ppThis != NULL); \
+ ASSERT(ppThis != NULL); \
\
if((pThis = (obj##_t *)calloc(1, sizeof(obj##_t))) == NULL) { \
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY); \
@@ -193,12 +194,57 @@ finalize_it: \
objConstructSetObjInfo(pThis); \
\
obj##Initialize(pThis); \
- \
+ \
finalize_it: \
OBJCONSTRUCT_CHECK_SUCCESS_AND_CLEANUP \
RETiRet; \
}
+/* this defines the destructor. The important point is that the base object
+ * destructor is called. The upper-level class shall destruct all of its
+ * properties, but not the instance itself. This is freed here by the
+ * framework (we need an intact pointer because we need to free the
+ * obj_t structures inside it). A pointer to the object pointer must be
+ * parse, because it is re-set to NULL (this, for example, is important in
+ * cancellation handlers). The object pointer is always named pThis.
+ * The object is always freed, even if there is some error while
+ * Cancellation is blocked during destructors, as this could have fatal
+ * side-effects. However, this also means the upper-level object should
+ * not perform any lenghty processing.
+ * IMPORTANT: if the upper level object requires some situations where the
+ * object shall not be destructed (e.g. via reference counting), then
+ * it shall set pThis to NULL, which prevents destruction of the
+ * object.
+ * processing.
+ * rgerhards, 2008-01-30
+ */
+#define BEGINobjDestruct(obj) \
+ rsRetVal obj##Destruct(obj##_t **ppThis) \
+ { \
+ DEFiRet; \
+ int iCancelStateSave; \
+ obj##_t *pThis;
+
+#define CODESTARTobjDestruct(obj) \
+ ASSERT(ppThis != NULL); \
+ pThis = *ppThis; \
+ ISOBJ_TYPE_assert(pThis, obj); \
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave);
+
+#define ENDobjDestruct(obj) \
+ goto finalize_it; /* prevent compiler warning ;) */ \
+ /* no more code here! */ \
+ finalize_it: \
+ if(pThis != NULL) { \
+ objDestructObjSelf((obj_t*) pThis); \
+ free(pThis); \
+ *ppThis = NULL; \
+ } \
+ pthread_setcancelstate(iCancelStateSave, NULL); \
+ RETiRet; \
+ }
+
+
#endif /* #ifndef OBJ_TYPES_H_INCLUDED */
diff --git a/obj.c b/obj.c
index 9181dec9..1ae3b109 100644
--- a/obj.c
+++ b/obj.c
@@ -116,6 +116,21 @@ rsRetVal objInfoSetMethod(objInfo_t *pThis, objMethod_t objMethod, rsRetVal (*pH
return RS_RET_OK;
}
+/* destruct the base object properties.
+ * rgerhards, 2008-01-29
+ */
+rsRetVal
+objDestructObjSelf(obj_t *pThis)
+{
+ DEFiRet;
+
+ ISOBJ_assert(pThis);
+ if(pThis->pszName != NULL)
+ free(pThis->pszName);
+
+ RETiRet;
+}
+
/* --------------- object serializiation / deserialization support --------------- */
diff --git a/obj.h b/obj.h
index 3eb3f194..0a89b74a 100644
--- a/obj.h
+++ b/obj.h
@@ -87,6 +87,7 @@
/* prototypes */
rsRetVal objInfoConstruct(objInfo_t **ppThis, objID_t objID, uchar *pszName, int iObjVers, rsRetVal (*pConstruct)(void *), rsRetVal (*pDestruct)(void *));
+rsRetVal objDestructObjSelf(obj_t *pThis);
rsRetVal objInfoSetMethod(objInfo_t *pThis, objMethod_t objMethod, rsRetVal (*pHandler)(void*));
rsRetVal objBeginSerializePropBag(strm_t *pStrm, obj_t *pObj);
rsRetVal objBeginSerialize(strm_t *pStrm, obj_t *pObj);
diff --git a/plugins/imklog/imklog.c b/plugins/imklog/imklog.c
index d4007899..825ebcf4 100644
--- a/plugins/imklog/imklog.c
+++ b/plugins/imklog/imklog.c
@@ -130,7 +130,7 @@ static rsRetVal writeSyslogV(int iPRI, const char *szFmt, va_list va)
/* here we must create our message object and supply it to the message queue
*/
- CHKiRet(MsgConstruct(&pMsg));
+ CHKiRet(msgConstruct(&pMsg));
MsgSetUxTradMsg(pMsg, msgBuf);
MsgSetRawMsg(pMsg, msgBuf);
MsgSetMSG(pMsg, (msgBuf + iLen));
diff --git a/queue.c b/queue.c
index ce5ed9d9..b1309ba2 100644
--- a/queue.c
+++ b/queue.c
@@ -684,7 +684,7 @@ RUNLOG_VAR("%d", iUngottenObjs);
while(iUngottenObjs > 0) {
RUNLOG_VAR("%d", iUngottenObjs);
/* fill the queue from disk */
- CHKiRet(objDeserialize((void*) &pUsr, OBJMsg, psQIF, NULL, NULL));
+ CHKiRet(objDeserialize((void*) &pUsr, OBJmsg, psQIF, NULL, NULL));
queueUngetObj(pThis, pUsr, MUTEX_ALREADY_LOCKED);
--iUngottenObjs; /* one less */
}
@@ -803,7 +803,7 @@ finalize_it:
static rsRetVal qDelDisk(queue_t *pThis, void **ppUsr)
{
- return objDeserialize(ppUsr, OBJMsg, pThis->tVars.disk.pRead, NULL, NULL);
+ return objDeserialize(ppUsr, OBJmsg, pThis->tVars.disk.pRead, NULL, NULL);
}
/* -------------------- direct (no queueing) -------------------- */
@@ -1219,7 +1219,7 @@ rsRetVal queueConstruct(queue_t **ppThis, queueType_t qType, int iWorkerThreads,
pThis->qConstruct = qConstructLinkedList;
pThis->qDestruct = qDestructLinkedList;
pThis->qAdd = qAddLinkedList;
- pThis->qDel = qDelLinkedList;
+ pThis->qDel = (rsRetVal (*)(queue_t*,void**)) qDelLinkedList;
break;
case QUEUETYPE_DISK:
pThis->qConstruct = qConstructDisk;
@@ -1728,15 +1728,8 @@ rsRetVal queueChkPersist(queue_t *pThis)
/* destructor for the queue object */
-rsRetVal queueDestruct(queue_t **ppThis)
-{
- DEFiRet;
- queue_t *pThis;
-
- ASSERT(ppThis != NULL);
- pThis = *ppThis;
- ISOBJ_TYPE_assert(pThis, queue);
-
+BEGINobjDestruct(queue) /* be sure to specify the object type also in END and CODESTART macros! */
+CODESTARTobjDestruct(queue)
pThis->bQueueInDestruction = 1; /* indicate we are in destruction (modifies some behaviour) */
/* shut down all workers (handles *all* of the persistence logic)
@@ -1758,7 +1751,6 @@ rsRetVal queueDestruct(queue_t **ppThis)
if(pThis->qType != QUEUETYPE_DIRECT && pThis->pWtpReg != NULL) {
wtpDestruct(&pThis->pWtpReg);
}
-RUNLOG;
/* Now check if we actually have a DA queue and, if so, destruct it.
* Note that the wtp must be destructed first, it may be in cancel cleanup handler
@@ -1766,16 +1758,12 @@ RUNLOG;
* data (re-queueing case). So we need to destruct the wtp first, which will make
* sure all workers have terminated.
*/
-RUNLOG_VAR("%p", pThis->pWtpDA);
if(pThis->pWtpDA != NULL) {
-RUNLOG;
wtpDestruct(&pThis->pWtpDA);
-RUNLOG_VAR("%p", pThis->pqDA);
}
if(pThis->pqDA != NULL) {
queueDestruct(&pThis->pqDA);
}
-RUNLOG;
/* persist the queue (we always do that - queuePersits() does cleanup if the queue is empty)
* This handler is most important for disk queues, it will finally persist the necessary
@@ -1804,13 +1792,7 @@ RUNLOG;
if(pThis->pszFilePrefix != NULL)
free(pThis->pszFilePrefix);
-
- /* and finally delete the queue objet itself */
- free(pThis);
- *ppThis = NULL;
-
- RETiRet;
-}
+ENDobjDestruct(queue)
/* set the queue's file prefix
diff --git a/stream.c b/stream.c
index cb6d5e29..0f756d1c 100644
--- a/stream.c
+++ b/stream.c
@@ -324,15 +324,8 @@ finalize_it:
/* destructor for the strm object */
-rsRetVal strmDestruct(strm_t **ppThis)
-{
- strm_t *pThis;
- DEFiRet;
-
- assert(ppThis != NULL);
- pThis = *ppThis;
- ISOBJ_TYPE_assert(pThis, strm);
-
+BEGINobjDestruct(strm) /* be sure to specify the object type also in END and CODESTART macros! */
+CODESTARTobjDestruct(strm)
if(pThis->tOperationsMode == STREAMMODE_WRITE)
strmFlush(pThis);
@@ -342,13 +335,7 @@ rsRetVal strmDestruct(strm_t **ppThis)
if(pThis->pszDir != NULL)
free(pThis->pszDir);
-
- /* and finally delete the strm objet itself */
- free(pThis);
- *ppThis = NULL;
-
- RETiRet;
-}
+ENDobjDestruct(strm)
/* check if we need to open a new file (in output mode only).
diff --git a/syslogd.c b/syslogd.c
index 574100a5..b4983513 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -1271,7 +1271,7 @@ rsRetVal printline(char *hname, char *msg, int bParseHost)
/* Now it is time to create the message object (rgerhards)
*/
- CHKiRet(MsgConstruct(&pMsg));
+ CHKiRet(msgConstruct(&pMsg));
MsgSetRawMsg(pMsg, msg);
pMsg->bParseHOSTNAME = bParseHost;
@@ -1510,7 +1510,7 @@ logmsgInternal(int pri, char *msg, int flags)
DEFiRet;
msg_t *pMsg;
- CHKiRet(MsgConstruct(&pMsg));
+ CHKiRet(msgConstruct(&pMsg));
MsgSetUxTradMsg(pMsg, msg);
MsgSetRawMsg(pMsg, msg);
MsgSetHOSTNAME(pMsg, LocalHostName);
@@ -1747,7 +1747,7 @@ msgConsumer(void __attribute__((unused)) *notNeeded, void *pUsr)
assert(pMsg != NULL);
processMsg(pMsg);
- MsgDestruct(&pMsg);
+ msgDestruct(&pMsg);
RETiRet;
}
@@ -2167,14 +2167,14 @@ logmsg(int pri, msg_t *pMsg, int flags)
dbgprintf("Message has syslog-protocol format.\n");
setProtocolVersion(pMsg, 1);
if(parseRFCSyslogMsg(pMsg, flags) == 1) {
- MsgDestruct(&pMsg);
+ msgDestruct(&pMsg);
return;
}
} else { /* we have legacy syslog */
dbgprintf("Message has legacy syslog format.\n");
setProtocolVersion(pMsg, 0);
if(parseLegacySyslogMsg(pMsg, flags) == 1) {
- MsgDestruct(&pMsg);
+ msgDestruct(&pMsg);
return;
}
}
@@ -4521,7 +4521,7 @@ static rsRetVal InitGlobalClasses(void)
DEFiRet;
CHKiRet(objClassInit()); /* *THIS* *MUST* always be the first class initilizere called! */
- CHKiRet(MsgClassInit());
+ CHKiRet(msgClassInit());
CHKiRet(strmClassInit());
CHKiRet(wtiClassInit());
CHKiRet(wtpClassInit());
diff --git a/wti.c b/wti.c
index dd0e465e..f938be3b 100644
--- a/wti.c
+++ b/wti.c
@@ -144,19 +144,8 @@ wtiSetState(wti_t *pThis, qWrkCmd_t tCmd, int bActiveOnly, int bLockMutex)
/* Destructor */
-rsRetVal wtiDestruct(wti_t **ppThis)
-{
- DEFiRet;
- wti_t *pThis;
- int iCancelStateSave;
-
- assert(ppThis != NULL);
- pThis = *ppThis;
- ISOBJ_TYPE_assert(pThis, wti);
-
- /* we can not be canceled, that would have a myriad of side-effects */
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave);
-
+BEGINobjDestruct(wti) /* be sure to specify the object type also in END and CODESTART macros! */
+CODESTARTobjDestruct(wti)
/* if we reach this point, we must make sure the associated worker has terminated. It is
* the callers duty to make sure the worker already knows it shall terminate.
* TODO: is it *really* the caller's duty? ...mmmhhhh.... smells bad... rgerhards, 2008-01-25
@@ -180,16 +169,7 @@ rsRetVal wtiDestruct(wti_t **ppThis)
if(pThis->pszDbgHdr != NULL)
free(pThis->pszDbgHdr);
-
- /* and finally delete the wti object itself */
- free(pThis);
- *ppThis = NULL;
-
- /* back to normal */
- pthread_setcancelstate(iCancelStateSave, NULL);
-
- RETiRet;
-}
+ENDobjDestruct(wti)
/* Standard-Constructor for the wti object
diff --git a/wtp.c b/wtp.c
index 69ca353b..7b34076a 100644
--- a/wtp.c
+++ b/wtp.c
@@ -125,21 +125,9 @@ finalize_it:
/* Destructor */
-rsRetVal
-wtpDestruct(wtp_t **ppThis)
-{
- DEFiRet;
- wtp_t *pThis;
- int iCancelStateSave;
+BEGINobjDestruct(wtp) /* be sure to specify the object type also in END and CODESTART macros! */
int i;
-
- assert(ppThis != NULL);
- pThis = *ppThis;
- ISOBJ_TYPE_assert(pThis, wtp);
-
- /* we can not be canceled, that would have a myriad of side-effects */
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave);
-
+CODESTARTobjDestruct(wtp)
/* destruct workers */
for(i = 0 ; i < pThis->iNumWorkerThreads ; ++i)
wtiDestruct(&pThis->pWrkr[i]);
@@ -153,16 +141,7 @@ wtpDestruct(wtp_t **ppThis)
if(pThis->pszDbgHdr != NULL)
free(pThis->pszDbgHdr);
-
- /* and finally delete the queue objet itself */
- free(pThis);
- *ppThis = NULL;
-
- /* back to normal */
- pthread_setcancelstate(iCancelStateSave, NULL);
-
- RETiRet;
-}
+ENDobjDestruct(wtp)
/* wake up at least one worker thread.