flow engine: remove unneeded 'need_srclock' argument for FlowRequeue

remotes/origin/master-1.2.x
Victor Julien 14 years ago
parent 0331da9773
commit fbbdbb251f

@ -405,7 +405,7 @@ Flow *FlowGetFlowFromHash (Packet *p)
f->flags |= FLOW_NEW_LIST; f->flags |= FLOW_NEW_LIST;
f->fb = fb; f->fb = fb;
FlowRequeue(f, NULL, &flow_new_q[f->protomap], 1); FlowRequeue(f, NULL, &flow_new_q[f->protomap]);
SCSpinUnlock(&fb->s); SCSpinUnlock(&fb->s);
FlowHashCountUpdate; FlowHashCountUpdate;
@ -443,7 +443,7 @@ Flow *FlowGetFlowFromHash (Packet *p)
f->flags |= FLOW_NEW_LIST; f->flags |= FLOW_NEW_LIST;
f->fb = fb; f->fb = fb;
FlowRequeue(f, NULL, &flow_new_q[f->protomap], 1); FlowRequeue(f, NULL, &flow_new_q[f->protomap]);
SCSpinUnlock(&fb->s); SCSpinUnlock(&fb->s);
FlowHashCountUpdate; FlowHashCountUpdate;

@ -116,36 +116,38 @@ Flow *FlowDequeue (FlowQueue *q) {
* \param srcq the source queue, where the flow will be removed. The param may * \param srcq the source queue, where the flow will be removed. The param may
* be NULL. * be NULL.
* \param dstq the dest queue where the flow will be placed * \param dstq the dest queue where the flow will be placed
* \param need_srclock does the srcq need locking? 1 yes, 0 no
* *
*/ */
void FlowRequeue(Flow *f, FlowQueue *srcq, FlowQueue *dstq, uint8_t need_srclock) void FlowRequeue(Flow *f, FlowQueue *srcq, FlowQueue *dstq)
{ {
#ifdef DEBUG #ifdef DEBUG
BUG_ON(dstq == NULL); BUG_ON(dstq == NULL);
#endif /* DEBUG */ #endif /* DEBUG */
if (srcq != NULL) { if (srcq != NULL) {
if (need_srclock == 1) { SCMutexLock(&srcq->mutex_q);
SCMutexLock(&srcq->mutex_q);
}
/* remove from old queue */ /* remove from old queue */
if (srcq->top == f) if (srcq->top == f)
srcq->top = f->lnext; /* remove from queue top */ srcq->top = f->lnext; /* remove from queue top */
if (srcq->bot == f) if (srcq->bot == f)
srcq->bot = f->lprev; /* remove from queue bot */ srcq->bot = f->lprev; /* remove from queue bot */
if (f->lprev) if (f->lprev != NULL)
f->lprev->lnext = f->lnext; /* remove from flow prev */ f->lprev->lnext = f->lnext; /* remove from flow prev */
if (f->lnext) if (f->lnext != NULL)
f->lnext->lprev = f->lprev; /* remove from flow next */ f->lnext->lprev = f->lprev; /* remove from flow next */
srcq->len--; /* adjust len */ #ifdef DEBUG
BUG_ON(srcq->len == 0);
#endif
if (srcq->len > 0)
srcq->len--; /* adjust len */
f->lnext = NULL; f->lnext = NULL;
f->lprev = NULL; f->lprev = NULL;
/* don't unlock if src and dst are the same */ /* don't unlock if src and dst are the same */
if (srcq != dstq && need_srclock == 1) { if (srcq != dstq) {
SCMutexUnlock(&srcq->mutex_q); SCMutexUnlock(&srcq->mutex_q);
} }
} }
@ -157,7 +159,7 @@ void FlowRequeue(Flow *f, FlowQueue *srcq, FlowQueue *dstq, uint8_t need_srclock
/* add to new queue (append) */ /* add to new queue (append) */
f->lprev = dstq->bot; f->lprev = dstq->bot;
if (f->lprev) if (f->lprev != NULL)
f->lprev->lnext = f; f->lprev->lnext = f;
f->lnext = NULL; f->lnext = NULL;
dstq->bot = f; dstq->bot = f;

@ -47,7 +47,8 @@ void FlowQueueDestroy (FlowQueue *);
void FlowEnqueue (FlowQueue *, Flow *); void FlowEnqueue (FlowQueue *, Flow *);
Flow *FlowDequeue (FlowQueue *); Flow *FlowDequeue (FlowQueue *);
void FlowRequeue(Flow *, FlowQueue *, FlowQueue *, uint8_t);
void FlowRequeue(Flow *, FlowQueue *, FlowQueue *);
void FlowRequeueMoveToBot(Flow *, FlowQueue *); void FlowRequeueMoveToBot(Flow *, FlowQueue *);
void FlowRequeueMoveToSpare(Flow *, FlowQueue *); void FlowRequeueMoveToSpare(Flow *, FlowQueue *);

@ -107,7 +107,7 @@ void FlowUpdateQueue(Flow *f)
/* in the new list -- we consider a flow no longer /* in the new list -- we consider a flow no longer
* new if we have seen at least 2 pkts in both ways. */ * new if we have seen at least 2 pkts in both ways. */
if (f->flags & FLOW_TO_DST_SEEN && f->flags & FLOW_TO_SRC_SEEN) { if (f->flags & FLOW_TO_DST_SEEN && f->flags & FLOW_TO_SRC_SEEN) {
FlowRequeue(f, &flow_new_q[f->protomap], &flow_est_q[f->protomap], 1); FlowRequeue(f, &flow_new_q[f->protomap], &flow_est_q[f->protomap]);
f->flags |= FLOW_EST_LIST; /* transition */ f->flags |= FLOW_EST_LIST; /* transition */
f->flags &= ~FLOW_NEW_LIST; f->flags &= ~FLOW_NEW_LIST;
@ -122,7 +122,7 @@ void FlowUpdateQueue(Flow *f)
f->flags &=~ FLOW_EST_LIST; f->flags &=~ FLOW_EST_LIST;
SCLogDebug("flow %p was put into closing queue ts %"PRIuMAX"", f, (uintmax_t)f->lastts_sec); SCLogDebug("flow %p was put into closing queue ts %"PRIuMAX"", f, (uintmax_t)f->lastts_sec);
FlowRequeue(f, &flow_est_q[f->protomap], &flow_close_q[f->protomap], 1); FlowRequeue(f, &flow_est_q[f->protomap], &flow_close_q[f->protomap]);
} else { } else {
/* Pull and put back -- this way the flows on /* Pull and put back -- this way the flows on
* top of the list are least recently used. */ * top of the list are least recently used. */
@ -144,7 +144,7 @@ void FlowUpdateQueue(Flow *f)
f->flags &=~ FLOW_CLOSED_LIST; f->flags &=~ FLOW_CLOSED_LIST;
SCLogDebug("flow %p was put into new queue ts %"PRIuMAX"", f, (uintmax_t)f->lastts_sec); SCLogDebug("flow %p was put into new queue ts %"PRIuMAX"", f, (uintmax_t)f->lastts_sec);
FlowRequeue(f, &flow_close_q[f->protomap], &flow_new_q[f->protomap], 1); FlowRequeue(f, &flow_close_q[f->protomap], &flow_new_q[f->protomap]);
} else { } else {
/* Pull and put back -- this way the flows on /* Pull and put back -- this way the flows on
* top of the list are least recently used. */ * top of the list are least recently used. */

Loading…
Cancel
Save