From 3b0142fa464016de53d0bee03dcbcb10b9e27ed8 Mon Sep 17 00:00:00 2001 From: Anoop Saldanha Date: Fri, 9 Sep 2011 21:56:10 +0530 Subject: [PATCH] update flow pruning - v3 --- src/flow.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/flow.c b/src/flow.c index 6285992f01..a8ecc9e174 100644 --- a/src/flow.c +++ b/src/flow.c @@ -612,14 +612,30 @@ static int FlowPrune(ThreadVars *tv, FlowQueue *q, struct timeval *ts) * we are currently processing in one of the threads */ if (SC_ATOMIC_GET(f->use_cnt) > 0) { SCLogDebug("timed out but use_cnt > 0: %"PRIu16", %p, proto %"PRIu8"", SC_ATOMIC_GET(f->use_cnt), f, f->proto); - SCSpinUnlock(&f->fb->s); - SCMutexUnlock(&f->m); SCLogDebug("it is in one of the threads"); #ifdef FLOW_PRUNE_DEBUG prune_usecnt++; #endif - return cnt; + int mr = SCMutexTrylock(&q->mutex_q); + if (mr != 0) { + SCLogDebug("trylock failed"); + if (mr == EBUSY) + SCLogDebug("was locked"); + if (mr == EINVAL) + SCLogDebug("bad mutex value"); +#ifdef FLOW_PRUNE_DEBUG + prune_queue_lock++; +#endif + SCSpinUnlock(&f->fb->s); + SCMutexUnlock(&f->m); + return cnt; + } + Flow *prev_f = f; + f = f->lnext; + SCSpinUnlock(&prev_f->fb->s); + SCMutexUnlock(&prev_f->m); + goto FlowPrune_Prune_Next; } if (FlowForceReassemblyForFlowV2(tv, f) == 1) {