From 57722664bcdfcd7be425ad3db02a884ff8c17f47 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 13 Apr 2011 15:55:38 +0200 Subject: bugfix (kind of): memory leak with tcp reception epoll handler This was an extremely unlikely leak and, if it happend, quite small. Still it is better to handle this border case. --- runtime/nsdpoll_ptcp.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'runtime/nsdpoll_ptcp.c') diff --git a/runtime/nsdpoll_ptcp.c b/runtime/nsdpoll_ptcp.c index 78203292..8c90d7fd 100644 --- a/runtime/nsdpoll_ptcp.c +++ b/runtime/nsdpoll_ptcp.c @@ -159,9 +159,19 @@ ENDobjConstruct(nsdpoll_ptcp) /* destructor for the nsdpoll_ptcp object */ BEGINobjDestruct(nsdpoll_ptcp) /* be sure to specify the object type also in END and CODESTART macros! */ + nsdpoll_epollevt_lst_t *node; + nsdpoll_epollevt_lst_t *nextnode; CODESTARTobjDestruct(nsdpoll_ptcp) - //printf("ndspoll_ptcp destruct, event list root is %p\n", pThis->pRoot); -#warning cleanup event list is missing! (at least I think so) + /* we check if the epoll list still holds entries. This may happen, but + * is a bit unusual. + */ + if(pThis->pRoot != NULL) { + for(node = pThis->pRoot ; node != NULL ; node = nextnode) { + nextnode = node->pNext; + dbgprintf("nsdpoll_ptcp destruct, need to destruct node %p\n", node); + delEvent(&node); + } + } pthread_mutex_destroy(&pThis->mutEvtLst); ENDobjDestruct(nsdpoll_ptcp) -- cgit v1.2.3