From: Anoop Saldanha Date: Thu, 12 Jan 2012 11:23:02 +0000 (+0530) Subject: Support freeing flow q handler out ctx. Adapt unittests to use the same X-Git-Tag: suricata-1.3beta1~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3faed5fe794fb1d6fdd3d7ae7542c4313fbb639b;p=thirdparty%2Fsuricata.git Support freeing flow q handler out ctx. Adapt unittests to use the same --- diff --git a/src/tmqh-flow.c b/src/tmqh-flow.c index 7cd1072c2d..038a8fd8d3 100644 --- a/src/tmqh-flow.c +++ b/src/tmqh-flow.c @@ -44,6 +44,7 @@ void TmqhOutputFlowActiveFlows(ThreadVars *t, Packet *p); void TmqhOutputFlowActivePackets(ThreadVars *t, Packet *p); void TmqhOutputFlowRoundRobin(ThreadVars *t, Packet *p); void *TmqhOutputFlowSetupCtx(char *queue_str); +void TmqhOutputFlowFreeCtx(void *ctx); void TmqhFlowRegisterTests(void); TmqhFlowCtx *tmqh_flow_outctx = NULL; @@ -53,7 +54,7 @@ void TmqhFlowRegister(void) tmqh_table[TMQH_FLOW].name = "flow"; tmqh_table[TMQH_FLOW].InHandler = TmqhInputFlow; tmqh_table[TMQH_FLOW].OutHandlerCtxSetup = TmqhOutputFlowSetupCtx; - tmqh_table[TMQH_FLOW].OutHandlerCtxFree = NULL; + tmqh_table[TMQH_FLOW].OutHandlerCtxFree = TmqhOutputFlowFreeCtx; tmqh_table[TMQH_FLOW].RegisterTests = TmqhFlowRegisterTests; char *scheduler = NULL; @@ -194,6 +195,22 @@ error: return NULL; } +void TmqhOutputFlowFreeCtx(void *ctx) +{ + int i; + TmqhFlowCtx *fctx = (TmqhFlowCtx *)ctx; + + for (i = 0; i < fctx->size; i++) { + SC_ATOMIC_DESTROY(fctx->queues[i].active_flows); + } + + SCFree(fctx->queues); + + tmqh_flow_outctx = NULL; + + return; +} + /** * \brief select the queue to output in a round robin fashion. * @@ -398,6 +415,8 @@ static int TmqhOutputFlowSetupCtxTest01(void) retval = 1; end: + if (fctx != NULL) + TmqhOutputFlowFreeCtx(fctx); TmqResetQueues(); return retval; } @@ -441,6 +460,8 @@ static int TmqhOutputFlowSetupCtxTest02(void) retval = 1; end: + if (fctx != NULL) + TmqhOutputFlowFreeCtx(fctx); TmqResetQueues(); return retval; } @@ -476,6 +497,8 @@ static int TmqhOutputFlowSetupCtxTest03(void) retval = 1; end: + if (fctx != NULL) + TmqhOutputFlowFreeCtx(fctx); TmqResetQueues(); return retval; }