From e055d4921b9a53e9dfedc56bbff3a9b12400d34d Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Sat, 5 Jan 2008 13:05:17 +0000 Subject: added capability for concurrent access to the msg class. Can be dynamically activated. If active, locking is employed. --- msg.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'msg.h') diff --git a/msg.h b/msg.h index 2168fb4c..7b2d2d43 100644 --- a/msg.h +++ b/msg.h @@ -25,6 +25,7 @@ #ifndef MSG_H_INCLUDED #define MSG_H_INCLUDED 1 +#include #include "obj.h" #include "syslogd-types.h" #include "template.h" @@ -46,6 +47,8 @@ */ struct msg { BEGINobjInstance; /* Data to implement generic object - MUST be the first data element! */ + pthread_mutexattr_t mutAttr; + pthread_mutex_t mut; int iRefCount; /* reference counter (0 = unused) */ short iSyslogVers; /* version of syslog protocol * 0 - RFC 3164 @@ -128,7 +131,6 @@ char *getSeverityStr(msg_t *pM); char *getFacility(msg_t *pM); char *getFacilityStr(msg_t *pM); rsRetVal MsgSetAPPNAME(msg_t *pMsg, char* pszAPPNAME); -int getAPPNAMELen(msg_t *pM); char *getAPPNAME(msg_t *pM); rsRetVal MsgSetPROCID(msg_t *pMsg, char* pszPROCID); int getPROCIDLen(msg_t *pM); @@ -155,6 +157,16 @@ char *getMSGID(msg_t *pM); char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, rsCStrObj *pCSPropName, unsigned short *pbMustBeFreed); char *textpri(char *pRes, size_t pResLen, int pri); +rsRetVal MsgEnableThreadSafety(void); + +/* The MsgPrepareEnqueue() function is a macro for performance reasons. + * It needs one global variable to work. This is acceptable, as it gains + * us quite some performance and is fully abstracted using this header file. + * The important thing is that no other module is permitted to actually + * access that global variable! -- rgerhards, 2008-01-05 + */ +extern void (*funcMsgPrepareEnqueue)(msg_t *pMsg); +#define MsgPrepareEnqueue(pMsg) funcMsgPrepareEnqueue(pMsg) #endif /* #ifndef MSG_H_INCLUDED */ /* -- cgit v1.2.3