summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/atomic.h2
-rw-r--r--runtime/debug.h1
-rw-r--r--runtime/msg.c1
-rw-r--r--runtime/msg.h13
-rw-r--r--runtime/parser.c3
-rw-r--r--runtime/queue.c5
6 files changed, 19 insertions, 6 deletions
diff --git a/runtime/atomic.h b/runtime/atomic.h
index 2dbe7f52..7ad8e2e4 100644
--- a/runtime/atomic.h
+++ b/runtime/atomic.h
@@ -42,12 +42,14 @@
*/
#ifdef HAVE_ATOMIC_BUILTINS
# define ATOMIC_INC(data) ((void) __sync_fetch_and_add(&(data), 1))
+# define ATOMIC_DEC(data) ((void) __sync_sub_and_fetch(&(data), 1))
# define ATOMIC_DEC_AND_FETCH(data) __sync_sub_and_fetch(&(data), 1)
# define ATOMIC_FETCH_32BIT(data) ((unsigned) __sync_fetch_and_and(&(data), 0xffffffff))
# define ATOMIC_STORE_1_TO_32BIT(data) __sync_lock_test_and_set(&(data), 1)
#else
# warning "atomic builtins not available, using nul operations"
# define ATOMIC_INC(data) (++(data))
+# define ATOMIC_DEC(data) (--(data))
# define ATOMIC_DEC_AND_FETCH(data) (--(data))
# define ATOMIC_FETCH_32BIT(data) (data)
# define ATOMIC_STORE_1_TO_32BIT(data) (data) = 1
diff --git a/runtime/debug.h b/runtime/debug.h
index 7ac29765..59b3e776 100644
--- a/runtime/debug.h
+++ b/runtime/debug.h
@@ -101,6 +101,7 @@ void dbgPrintAllDebugInfo(void);
/* macros */
#define DBGPRINTF(...) if(Debug) { dbgprintf(__VA_ARGS__); }
+#define DBGOPRINT(...) if(Debug) { dbgoprint(__VA_ARGS__); }
#ifdef RTINST
# define BEGINfunc static dbgFuncDB_t *pdbgFuncDB; int dbgCALLStaCK_POP_POINT = dbgEntrFunc(&pdbgFuncDB, __FILE__, __func__, __LINE__);
# define ENDfunc dbgExitFunc(pdbgFuncDB, dbgCALLStaCK_POP_POINT, RS_RET_NO_IRET);
diff --git a/runtime/msg.c b/runtime/msg.c
index e52c9e3f..c030fa45 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -264,7 +264,6 @@ static inline rsRetVal msgBaseConstruct(msg_t **ppThis)
/* initialize members that are non-zero */
pM->iRefCount = 1;
- pM->bIsParsed = 1; /* first we assume this is parsed. If not, input must re-set to 0 */
pM->iSeverity = -1;
pM->iFacility = -1;
objConstructSetObjInfo(pM);
diff --git a/runtime/msg.h b/runtime/msg.h
index 98635f85..d98111a8 100644
--- a/runtime/msg.h
+++ b/runtime/msg.h
@@ -55,7 +55,6 @@ struct msg {
flowControl_t flowCtlType; /**< type of flow control we can apply, for enqueueing, needs not to be persisted because
once data has entered the queue, this property is no longer needed. */
short iRefCount; /* reference counter (0 = unused) */
- short bIsParsed; /* is message parsed? (0=no, 1=yes), 0 means parser needs to be called */
short bParseHOSTNAME; /* should the hostname be parsed from the message? */
/* background: the hostname is not present on "regular" messages
* received via UNIX domain sockets from the same machine. However,
@@ -122,6 +121,18 @@ struct msg {
int msgFlags; /* flags associated with this message */
};
+
+/* message flags (msgFlags), not an enum for historical reasons
+ */
+#define NOFLAG 0x000 /* no flag is set (to be used when a flag must be specified and none is required) */
+#define INTERNAL_MSG 0x001 /* msg generated by logmsgInternal() --> special handling */
+/* 0x002 not used because it was previously a known value - rgerhards, 2008-10-09 */
+#define IGNDATE 0x004 /* ignore, if given, date in message and use date of reception as msg date */
+#define MARK 0x008 /* this message is a mark */
+#define NEEDS_PARSING 0x010 /* raw message, must be parsed before processing can be done */
+#define PARSE_HOSTNAME 0x020 /* parse the hostname during message parsing */
+
+
/* function prototypes
*/
PROTOTYPEObjClassInit(msg);
diff --git a/runtime/parser.c b/runtime/parser.c
index 8c4272a0..fbdeebeb 100644
--- a/runtime/parser.c
+++ b/runtime/parser.c
@@ -41,7 +41,6 @@
/* some defines */
#define DEFUPRI (LOG_USER|LOG_NOTICE)
-#warning "msg object must be updated with new property for persisting the queue!"
/* definitions for objects we access */
DEFobjStaticHelpers
DEFobjCurrIf(glbl)
@@ -306,7 +305,7 @@ rsRetVal parseMsg(msg_t *pMsg)
}
/* finalize message object */
- pMsg->bIsParsed = 1; /* this message is now parsed */
+ pMsg->msgFlags &= ~NEEDS_PARSING; /* this message is now parsed */
MsgPrepareEnqueue(pMsg); /* "historical" name - preparese for multi-threading */
finalize_it:
diff --git a/runtime/queue.c b/runtime/queue.c
index b0043ef5..42b8137d 100644
--- a/runtime/queue.c
+++ b/runtime/queue.c
@@ -49,6 +49,7 @@
#include "obj.h"
#include "wtp.h"
#include "wti.h"
+#include "atomic.h"
/* static data */
DEFobjStaticHelpers
@@ -996,7 +997,7 @@ queueAdd(queue_t *pThis, void *pUsr)
CHKiRet(pThis->qAdd(pThis, pUsr));
if(pThis->qType != QUEUETYPE_DIRECT) {
- ++pThis->iQueueSize;
+ ATOMIC_INC(pThis->iQueueSize);
dbgoprint((obj_t*) pThis, "entry added, size now %d entries\n", pThis->iQueueSize);
}
@@ -1025,7 +1026,7 @@ queueDel(queue_t *pThis, void *pUsr)
iRet = queueGetUngottenObj(pThis, (obj_t**) pUsr);
} else {
iRet = pThis->qDel(pThis, pUsr);
- --pThis->iQueueSize;
+ ATOMIC_DEC(pThis->iQueueSize);
}
dbgoprint((obj_t*) pThis, "entry deleted, state %d, size now %d entries\n",