summaryrefslogtreecommitdiffstats
path: root/runtime/prop.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-30 18:45:41 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-30 18:45:41 +0200
commitaaffc4281e0b26f419a3fc341461f2fc479080b8 (patch)
treef605da690f7e095c4a0bba4139c5f45cff687fef /runtime/prop.c
parente397c34d2a6c7c1e4c116fd2363cb173e32eb2a2 (diff)
downloadrsyslog-aaffc4281e0b26f419a3fc341461f2fc479080b8.tar.gz
rsyslog-aaffc4281e0b26f419a3fc341461f2fc479080b8.tar.xz
rsyslog-aaffc4281e0b26f419a3fc341461f2fc479080b8.zip
introduced a new way of handling the RcvFrom property
... plus a fix for a long-time bug in obj-types.h. That lead to the object pointer only then to become NULL when the object was actually destructed, I discovered this issue during introduction of the pRcvFrom property in msg_t, but it potentially had other effects, too. I am not sure if some experienced instability resulted from this bug OR if its fix will cause harm to so-far "correctly" running code. The later may very well be. Thus I will change it only for the current branch and also the beta, but not in all old builds. Let's see how things evolve.
Diffstat (limited to 'runtime/prop.c')
-rw-r--r--runtime/prop.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/runtime/prop.c b/runtime/prop.c
index 989657dd..96ebe212 100644
--- a/runtime/prop.c
+++ b/runtime/prop.c
@@ -68,7 +68,7 @@ static rsRetVal SetString(prop_t *pThis, uchar *psz, int len)
memcpy(pThis->szVal.sz, psz, len + 1);
} else {
CHKmalloc(pThis->szVal.psz = malloc(len + 1));
- memcpy(pThis->szVal.sz, psz, len + 1);
+ memcpy(pThis->szVal.psz, psz, len + 1);
}
finalize_it:
@@ -76,15 +76,25 @@ finalize_it:
}
+/* get string length */
+static int GetStringLen(prop_t *pThis)
+{
+ return pThis->len;
+}
+
+
/* get string */
static rsRetVal GetString(prop_t *pThis, uchar **ppsz, int *plen)
{
BEGINfunc
ISOBJ_TYPE_assert(pThis, prop);
- if(pThis->len < CONF_PROP_BUFSIZE)
+ if(pThis->len < CONF_PROP_BUFSIZE) {
*ppsz = pThis->szVal.sz;
- else
+RUNLOG;
+ } else {
*ppsz = pThis->szVal.psz;
+RUNLOG;
+ }
*plen = pThis->len;
ENDfunc
return RS_RET_OK;
@@ -120,7 +130,6 @@ CODESTARTobjDestruct(prop)
currRefCount = ATOMIC_DEC_AND_FETCH(pThis->iRefCount);
if(currRefCount == 0) {
/* (only) in this case we need to actually destruct the object */
-dbgprintf("XXXXX: propDestruct: ptr %p, pThis %p, len %d\n", pThis->szVal.psz, pThis, pThis->len);
if(pThis->len >= CONF_PROP_BUFSIZE)
free(pThis->szVal.psz);
} else {
@@ -156,6 +165,7 @@ CODESTARTobjQueryInterface(prop)
pIf->DebugPrint = propDebugPrint;
pIf->SetString = SetString;
pIf->GetString = GetString;
+ pIf->GetStringLen = GetStringLen;
pIf->AddRef = AddRef;
finalize_it: