/* tracker is locked */
hb->head = dt;
- hb->tail = dt;
/* got one, now lock, initialize and return */
DefragTrackerInit(dt,p);
DRLOCK_UNLOCK(hb);
return NULL;
}
- prev->hnext = hb->tail = dt;
- dt->hprev = prev;
+ prev->hnext = dt;
/* tracker is locked */
}
/* 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;
+ hb->head = dt->hnext;
dt->hnext = NULL;
- dt->hprev = NULL;
DRLOCK_UNLOCK(hb);
DefragTrackerClearMemory(dt);
{
uint32_t cnt = 0;
+ DefragTracker *prev_dt = NULL;
do {
if (SCMutexTrylock(&dt->lock) != 0) {
+ prev_dt = dt;
dt = dt->hnext;
continue;
}
/* check if the tracker is fully timed out and
* ready to be discarded. */
- if (DefragTrackerTimedOut(dt, ts) == 1) {
- /* 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;
-
- DefragTrackerClearMemory(dt);
-
- /* no one is referring to this tracker, use_cnt 0, removed from hash
- * so we can unlock it and move it back to the spare queue. */
+ if (DefragTrackerTimedOut(dt, ts) == 0) {
+ prev_dt = dt;
SCMutexUnlock(&dt->lock);
+ dt = next_dt;
+ continue;
+ }
- /* move to spare list */
- DefragTrackerMoveToSpare(dt);
-
- cnt++;
+ /* remove from the hash */
+ if (prev_dt != NULL) {
+ prev_dt->hnext = dt->hnext;
} else {
- SCMutexUnlock(&dt->lock);
+ hb->head = dt->hnext;
}
+ dt->hnext = NULL;
+
+ DefragTrackerClearMemory(dt);
+
+ /* no one is referring to this tracker, use_cnt 0, removed from hash
+ * so we can unlock it and move it back to the spare queue. */
+ SCMutexUnlock(&dt->lock);
+
+ /* move to spare list */
+ DefragTrackerMoveToSpare(dt);
+
+ cnt++;
+
dt = next_dt;
} while (dt != NULL);
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;