summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--runtime/nsdsel_gtls.c1
-rw-r--r--tcpsrv.c17
-rw-r--r--tests/Makefile.am3
-rwxr-xr-xtests/manytcp-too-few-tls.sh13
-rw-r--r--tests/testsuites/manytcp-too-few-tls.conf22
6 files changed, 55 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index d95fd2ea..78d48477 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------
+Version 6.3.2 [DEVEL] (rgerhards), 2011-06-07
+- 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.
+---------------------------------------------------------------------------
Version 6.3.1 [DEVEL] (rgerhards), 2011-06-07
- added a first implementation of a DNS name cache
this still has a couple of weaknesses, like no expiration of entries,
diff --git a/runtime/nsdsel_gtls.c b/runtime/nsdsel_gtls.c
index 1a389a00..aff55af2 100644
--- a/runtime/nsdsel_gtls.c
+++ b/runtime/nsdsel_gtls.c
@@ -177,6 +177,7 @@ doRetry(nsd_gtls_t *pNsd)
finalize_it:
if(iRet != RS_RET_OK && iRet != RS_RET_CLOSED && iRet != RS_RET_RETRY)
pNsd->bAbortConn = 1; /* request abort */
+dbgprintf("XXXXXX: doRetry: iRet %d, pNsd->bAbortConn %d\n", iRet, pNsd->bAbortConn);
RETiRet;
}
diff --git a/tcpsrv.c b/tcpsrv.c
index a8f69512..adb23e60 100644
--- a/tcpsrv.c
+++ b/tcpsrv.c
@@ -564,16 +564,18 @@ finalize_it:
static inline rsRetVal
processWorksetItem(tcpsrv_t *pThis, nspoll_t *pPoll, int idx, void *pUsr)
{
- tcps_sess_t *pNewSess;
+ tcps_sess_t *pNewSess = NULL;
DEFiRet;
- dbgprintf("tcpsrv: processing item %d, pUsr %p\n", idx, pUsr);
+ DBGPRINTF("tcpsrv: processing item %d, pUsr %p, bAbortConn\n", idx, pUsr);
if(pUsr == pThis->ppLstn) {
DBGPRINTF("New connect on NSD %p.\n", pThis->ppLstn[idx]);
iRet = SessAccept(pThis, pThis->ppLstnPort[idx], &pNewSess, pThis->ppLstn[idx]);
if(iRet == RS_RET_OK) {
- if(pPoll != NULL)
+ if(pPoll != NULL) {
+ dbgprintf("XXXXXX: processWorksetItem trying nspoll.ctl\n");
CHKiRet(nspoll.Ctl(pPoll, pNewSess->pStrm, 0, pNewSess, NSDPOLL_IN, NSDPOLL_ADD));
+ }
DBGPRINTF("New session created with NSD %p.\n", pNewSess);
} else {
DBGPRINTF("tcpsrv: error %d during accept\n", iRet);
@@ -702,6 +704,7 @@ RunSelect(tcpsrv_t *pThis, nsd_epworkset_t workset[], size_t sizeWorkset)
int iTCPSess;
int bIsReady;
nssel_t *pSel = NULL;
+ rsRetVal localRet;
ISOBJ_TYPE_assert(pThis, tcpsrv);
@@ -758,8 +761,8 @@ RunSelect(tcpsrv_t *pThis, nsd_epworkset_t workset[], size_t sizeWorkset)
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) {
workset[iWorkset].id = iTCPSess;
workset[iWorkset].pUsr = (void*) pThis->pSessions[iTCPSess];
++iWorkset;
@@ -783,7 +786,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 */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3be4f296..ed25c388 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -108,6 +108,7 @@ TESTS += \
if HAVE_VALGRIND
TESTS += imtcp-tls-basic-vg.sh \
imtcp_conndrop_tls-vg.sh
+ manytcp-too-few-tls-vg.sh
endif
endif
@@ -274,6 +275,8 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
testsuites/udp-msgreduc-orgmsg-vg.conf \
udp-msgreduc-vg.sh \
testsuites/udp-msgreduc-vg.conf \
+ manytcp-too-few-tls.sh \
+ testsuites/manytcp-too-few-tls.conf \
manytcp.sh \
testsuites/manytcp.conf \
manyptcp.sh \
diff --git a/tests/manytcp-too-few-tls.sh b/tests/manytcp-too-few-tls.sh
new file mode 100755
index 00000000..d4da5f8b
--- /dev/null
+++ b/tests/manytcp-too-few-tls.sh
@@ -0,0 +1,13 @@
+# test many concurrent tcp connections
+echo \[manytcp-too-few-tls.sh\]: test concurrent tcp connections
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup-vg manytcp-too-few-tls.conf
+# the config file specifies exactly 1100 connections
+source $srcdir/diag.sh tcpflood -c1000 -m40000
+# the sleep below is needed to prevent too-early termination of the tcp listener
+sleep 1
+source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
+source $srcdir/diag.sh wait-shutdown-vg # we need to wait until rsyslogd is finished!
+source $srcdir/diag.sh check-exit-vg
+source $srcdir/diag.sh seq-check 0 39999
+source $srcdir/diag.sh exit
diff --git a/tests/testsuites/manytcp-too-few-tls.conf b/tests/testsuites/manytcp-too-few-tls.conf
new file mode 100644
index 00000000..5269e73b
--- /dev/null
+++ b/tests/testsuites/manytcp-too-few-tls.conf
@@ -0,0 +1,22 @@
+# Test for tcp "flood" testing
+# rgerhards, 2009-04-08
+$IncludeConfig diag-common.conf
+
+$ModLoad ../plugins/imtcp/.libs/imtcp
+$MainMsgQueueTimeoutShutdown 10000
+$MaxOpenFiles 200
+$InputTCPMaxSessions 1100
+# certificates
+$DefaultNetstreamDriverCAFile testsuites/x.509/ca.pem
+$DefaultNetstreamDriverCertFile testsuites/x.509/client-cert.pem
+$DefaultNetstreamDriverKeyFile testsuites/x.509/client-key.pem
+
+$DefaultNetstreamDriver gtls # use gtls netstream driver
+
+$InputTCPServerStreamDriverMode 1
+$InputTCPServerStreamDriverAuthMode anon
+$InputTCPServerRun 13514
+
+$template outfmt,"%msg:F,58:2%\n"
+$template dynfile,"rsyslog.out.log" # trick to use relative path names!
+:msg, contains, "msgnum:" ?dynfile;outfmt