From e68ca2f32f87150bd2452dd85a044cedb198b9af Mon Sep 17 00:00:00 2001 From: Anoop Saldanha Date: Wed, 14 Sep 2011 21:47:00 +0530 Subject: [PATCH] Rewrite forced reassembly v2 using while loop instead of goto --- src/flow.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/flow.c b/src/flow.c index 1321b91e58..e98fe0cd0e 100644 --- a/src/flow.c +++ b/src/flow.c @@ -482,7 +482,7 @@ static int FlowPrune(FlowQueue *q, struct timeval *ts, int try_cnt) Flow *f = q->top; /* label */ - FlowPrune_Prune_Next: + while (f != NULL) { if (try_cnt != 0 && try_cnt_temp == try_cnt) { SCMutexUnlock(&q->mutex_q); return cnt; @@ -506,7 +506,7 @@ static int FlowPrune(FlowQueue *q, struct timeval *ts, int try_cnt) prune_flow_lock++; #endif f = f->lnext; - goto FlowPrune_Prune_Next; + continue; } if (SCSpinTrylock(&f->fb->s) != 0) { @@ -517,7 +517,7 @@ static int FlowPrune(FlowQueue *q, struct timeval *ts, int try_cnt) prune_bucket_lock++; #endif f = f->lnext; - goto FlowPrune_Prune_Next; + continue; } /*set the timeout value according to the flow operating mode, flow's state @@ -595,14 +595,14 @@ static int FlowPrune(FlowQueue *q, struct timeval *ts, int try_cnt) f = f->lnext; SCSpinUnlock(&prev_f->fb->s); SCMutexUnlock(&prev_f->m); - goto FlowPrune_Prune_Next; + continue; } if (FlowForceReassemblyForFlowV2(f) == 1) { Flow *prev_f = f; f = f->lnext; SCMutexUnlock(&prev_f->m); - goto FlowPrune_Prune_Next; + continue; } /* this should not be possible */ @@ -630,7 +630,10 @@ static int FlowPrune(FlowQueue *q, struct timeval *ts, int try_cnt) SCMutexUnlock(&f->m); f = next_flow; - goto FlowPrune_Prune_Next; + } + + SCMutexUnlock(&q->mutex_q); + return cnt; } /** \brief Time out flows.