summaryrefslogtreecommitdiffstats
path: root/tcps_sess.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 /tcps_sess.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 'tcps_sess.c')
-rw-r--r--tcps_sess.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/tcps_sess.c b/tcps_sess.c
index 23241f4f..c4dc4bd4 100644
--- a/tcps_sess.c
+++ b/tcps_sess.c
@@ -36,6 +36,7 @@
#include "rsyslog.h"
#include "dirty.h"
+#include "unicode-helper.h"
#include "module-template.h"
#include "net.h"
#include "tcpsrv.h"
@@ -102,7 +103,8 @@ CODESTARTobjDestruct(tcps_sess)
pThis->pSrv->pOnSessDestruct(&pThis->pUsr);
}
/* now destruct our own properties */
- free(pThis->fromHost);
+ if(pThis->fromHost != NULL)
+ CHKiRet(prop.Destruct(&pThis->fromHost));
free(pThis->fromHostIP);
free(pThis->pMsg);
ENDobjDestruct(tcps_sess)
@@ -126,9 +128,14 @@ SetHost(tcps_sess_t *pThis, uchar *pszHost)
ISOBJ_TYPE_assert(pThis, tcps_sess);
- free(pThis->fromHost);
- pThis->fromHost = pszHost;
+ if(pThis->fromHost == NULL) {
+ CHKiRet(prop.Construct(&pThis->fromHost));
+ }
+
+ CHKiRet(prop.SetString(pThis->fromHost, pszHost, ustrlen(pszHost)));
+finalize_it:
+ free(pszHost); /* we must free according to our (old) calling conventions */
RETiRet;
}
@@ -325,8 +332,9 @@ Close(tcps_sess_t *pThis)
ISOBJ_TYPE_assert(pThis, tcps_sess);
netstrm.Destruct(&pThis->pStrm);
- free(pThis->fromHost);
- pThis->fromHost = NULL; /* not really needed, but... */
+ if(pThis->fromHost != NULL) {
+ prop.Destruct(&pThis->fromHost);
+ }
free(pThis->fromHostIP);
pThis->fromHostIP = NULL; /* not really needed, but... */