flow engine: introduce FlowRequeueMoveToBot

As part of a clean up of how FlowRequeue is used, introduce
FlowRequeueMoveToBot for moving a flow to the bottom of it's queue.
remotes/origin/master-1.2.x
Victor Julien 14 years ago
parent ae1e4c1d7d
commit 7fa3df33f2

@ -172,3 +172,43 @@ void FlowRequeue(Flow *f, FlowQueue *srcq, FlowQueue *dstq, uint8_t need_srclock
SCMutexUnlock(&dstq->mutex_q);
}
/**
* \brief Move flow to bottom of queue
*
* \param f the flow to be transfered
* \param q the queue
*/
void FlowRequeueMoveToBot(Flow *f, FlowQueue *q)
{
#ifdef DEBUG
BUG_ON(q == NULL || f == NULL);
#endif /* DEBUG */
SCMutexLock(&q->mutex_q);
/* remove from the queue */
if (q->top == f)
q->top = f->lnext; /* remove from queue top */
if (q->bot == f)
q->bot = f->lprev; /* remove from queue bot */
if (f->lprev != NULL)
f->lprev->lnext = f->lnext; /* remove from flow prev */
if (f->lnext != NULL)
f->lnext->lprev = f->lprev; /* remove from flow next */
/* readd to the queue (append) */
f->lprev = q->bot;
if (f->lprev != NULL)
f->lprev->lnext = f;
f->lnext = NULL;
q->bot = f;
if (q->top == NULL)
q->top = f;
SCMutexUnlock(&q->mutex_q);
}

@ -48,6 +48,7 @@ void FlowQueueDestroy (FlowQueue *);
void FlowEnqueue (FlowQueue *, Flow *);
Flow *FlowDequeue (FlowQueue *);
void FlowRequeue(Flow *, FlowQueue *, FlowQueue *, uint8_t);
void FlowRequeueMoveToBot(Flow *, FlowQueue *);
#endif /* __FLOW_QUEUE_H__ */

@ -112,7 +112,7 @@ void FlowUpdateQueue(Flow *f)
f->flags |= FLOW_EST_LIST; /* transition */
f->flags &= ~FLOW_NEW_LIST;
} else {
FlowRequeue(f, &flow_new_q[f->protomap], &flow_new_q[f->protomap], 1);
FlowRequeueMoveToBot(f, &flow_new_q[f->protomap]);
}
} else if (f->flags & FLOW_EST_LIST) {
if (flow_proto[f->protomap].GetProtoState != NULL) {
@ -126,12 +126,12 @@ void FlowUpdateQueue(Flow *f)
} else {
/* Pull and put back -- this way the flows on
* top of the list are least recently used. */
FlowRequeue(f, &flow_est_q[f->protomap], &flow_est_q[f->protomap], 1);
FlowRequeueMoveToBot(f, &flow_est_q[f->protomap]);
}
} else {
/* Pull and put back -- this way the flows on
* top of the list are least recently used. */
FlowRequeue(f, &flow_est_q[f->protomap], &flow_est_q[f->protomap], 1);
FlowRequeueMoveToBot(f, &flow_est_q[f->protomap]);
}
} else if (f->flags & FLOW_CLOSED_LIST){
/* for the case of ssn reuse in TCP sessions we need to be able to pull
@ -148,12 +148,12 @@ void FlowUpdateQueue(Flow *f)
} else {
/* Pull and put back -- this way the flows on
* top of the list are least recently used. */
FlowRequeue(f, &flow_close_q[f->protomap], &flow_close_q[f->protomap], 1);
FlowRequeueMoveToBot(f, &flow_close_q[f->protomap]);
}
} else {
/* Pull and put back -- this way the flows on
* top of the list are least recently used. */
FlowRequeue(f, &flow_close_q[f->protomap], &flow_close_q[f->protomap], 1);
FlowRequeueMoveToBot(f, &flow_close_q[f->protomap]);
}
}

Loading…
Cancel
Save