defrag: turn hash row into single linked list

pull/11227/head
Victor Julien 9 months ago committed by Victor Julien
parent 26a73503aa
commit 8b57545540

@ -564,7 +564,6 @@ DefragTracker *DefragGetTrackerFromHash(ThreadVars *tv, DecodeThreadVars *dtv, P
/* tracker is locked */
hb->head = dt;
hb->tail = dt;
/* got one, now lock, initialize and return */
DefragTrackerInit(dt,p);
@ -591,8 +590,7 @@ DefragTracker *DefragGetTrackerFromHash(ThreadVars *tv, DecodeThreadVars *dtv, P
DRLOCK_UNLOCK(hb);
return NULL;
}
prev->hnext = hb->tail = dt;
dt->hprev = prev;
prev->hnext = dt;
/* tracker is locked */
@ -702,17 +700,9 @@ static DefragTracker *DefragTrackerGetUsedDefragTracker(void)
}
/* remove from the hash */
if (dt->hprev != NULL)
dt->hprev->hnext = dt->hnext;
if (dt->hnext != NULL)
dt->hnext->hprev = dt->hprev;
if (hb->head == dt)
hb->head = dt->hnext;
if (hb->tail == dt)
hb->tail = dt->hprev;
dt->hnext = NULL;
dt->hprev = NULL;
DRLOCK_UNLOCK(hb);
DefragTrackerClearMemory(dt);

@ -60,7 +60,6 @@
typedef struct DefragTrackerHashRow_ {
DRLOCK_TYPE lock;
DefragTracker *head;
DefragTracker *tail;
} DefragTrackerHashRow;
/** defrag tracker hash table */

@ -67,8 +67,10 @@ static uint32_t DefragTrackerHashRowTimeout(
{
uint32_t cnt = 0;
DefragTracker *prev_dt = NULL;
do {
if (SCMutexTrylock(&dt->lock) != 0) {
prev_dt = dt;
dt = dt->hnext;
continue;
}
@ -77,19 +79,21 @@ static uint32_t DefragTrackerHashRowTimeout(
/* check if the tracker is fully timed out and
* ready to be discarded. */
if (DefragTrackerTimedOut(dt, ts) == 1) {
if (DefragTrackerTimedOut(dt, ts) == 0) {
prev_dt = dt;
SCMutexUnlock(&dt->lock);
dt = next_dt;
continue;
}
/* remove from the hash */
if (dt->hprev != NULL)
dt->hprev->hnext = dt->hnext;
if (dt->hnext != NULL)
dt->hnext->hprev = dt->hprev;
if (hb->head == dt)
if (prev_dt != NULL) {
prev_dt->hnext = dt->hnext;
} else {
hb->head = dt->hnext;
if (hb->tail == dt)
hb->tail = dt->hprev;
}
dt->hnext = NULL;
dt->hprev = NULL;
DefragTrackerClearMemory(dt);
@ -101,9 +105,6 @@ static uint32_t DefragTrackerHashRowTimeout(
DefragTrackerMoveToSpare(dt);
cnt++;
} else {
SCMutexUnlock(&dt->lock);
}
dt = next_dt;
} while (dt != NULL);

@ -115,9 +115,8 @@ typedef struct DefragTracker_ {
struct IP_FRAGMENTS fragment_tree;
/** hash pointers, protected by hash row mutex/spin */
/** hash pointer, protected by hash row mutex/spin */
struct DefragTracker_ *hnext;
struct DefragTracker_ *hprev;
/** list pointers, protected by tracker-queue mutex/spin */
struct DefragTracker_ *lnext;

Loading…
Cancel
Save