summaryrefslogtreecommitdiffstats
path: root/tcpsrv.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-06-10 22:50:25 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-06-10 22:50:25 +0200
commit2c81df12bcbe85d819a43227cc9adb05d8d0fe29 (patch)
tree58652253f98d86a74b8a1ec385629f42308c3d1b /tcpsrv.c
parent2b5a7f10f5cde91a6463a23daeeb7fbab051e642 (diff)
downloadrsyslog-2c81df12bcbe85d819a43227cc9adb05d8d0fe29.tar.gz
rsyslog-2c81df12bcbe85d819a43227cc9adb05d8d0fe29.tar.xz
rsyslog-2c81df12bcbe85d819a43227cc9adb05d8d0fe29.zip
bugfix: memory leak in imtcp & subsystems under some circumstances
This leak is tied to error conditions which lead to incorrect cleanup of some data structures. Note: this is a backport from v6. In v5, we currently do not have the toolchain to verify the original problem and that it is solved. So this patch is preliminary and subject to change as work progresses.
Diffstat (limited to 'tcpsrv.c')
-rw-r--r--tcpsrv.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tcpsrv.c b/tcpsrv.c
index 9972a135..0b822511 100644
--- a/tcpsrv.c
+++ b/tcpsrv.c
@@ -556,6 +556,7 @@ RunSelect(tcpsrv_t *pThis)
int bIsReady;
tcps_sess_t *pNewSess;
nssel_t *pSel = NULL;
+ rsRetVal localRet;
ISOBJ_TYPE_assert(pThis, tcpsrv);
@@ -604,8 +605,8 @@ RunSelect(tcpsrv_t *pThis)
while(nfds && iTCPSess != -1) {
if(glbl.GetGlobalInputTermState() == 1)
ABORT_FINALIZE(RS_RET_FORCE_TERM);
- CHKiRet(nssel.IsReady(pSel, pThis->pSessions[iTCPSess]->pStrm, NSDSEL_RD, &bIsReady, &nfds));
- if(bIsReady) {
+ localRet = nssel.IsReady(pSel, pThis->pSessions[iTCPSess]->pStrm, NSDSEL_RD, &bIsReady, &nfds);
+ if(bIsReady || localRet != RS_RET_OK) {
doReceive(pThis, &pThis->pSessions[iTCPSess], NULL);
--nfds; /* indicate we have processed one */
}
@@ -618,7 +619,9 @@ finalize_it: /* this is a very special case - this time only we do not exit the
* crashed, which made sense (the rest of the engine was not prepared for
* that) -- rgerhards, 2008-05-19
*/
- /*EMPTY*/;
+ if(pSel != NULL) { /* cleanup missing? happens during err exit! */
+ nssel.Destruct(&pSel);
+ }
}
/* note that this point is usually not reached */