Revert "detect/state: optimize state keeping"

This reverts commit 13ce474d5e.

The optimization is incomplete. A more complete fix is merged in
master, but this needs a bit more time before getting backported.
pull/5962/head
Victor Julien 5 years ago
parent 90fdb53439
commit 01384bc780

@ -123,23 +123,27 @@ static int DeStateSearchState(DetectEngineState *state, uint8_t direction, SigIn
static void DeStateSignatureAppend(DetectEngineState *state,
const Signature *s, uint32_t inspect_flags, uint8_t direction)
{
SCEnter();
int jump = 0;
int i = 0;
DetectEngineStateDirection *dir_state = &state->dir_state[direction & STREAM_TOSERVER ? 0 : 1];
#ifdef DEBUG_VALIDATION
BUG_ON(DeStateSearchState(state, direction, s->num));
#endif
DeStateStore *store = dir_state->tail;
DeStateStore *store = dir_state->head;
if (store == NULL) {
store = DeStateStoreAlloc();
dir_state->head = store;
dir_state->tail = store;
if (store != NULL) {
dir_state->head = store;
dir_state->tail = store;
}
} else {
SCLogDebug("dir_state->cnt %u mod chunksize %u", dir_state->cnt,
dir_state->cnt % DE_STATE_CHUNK_SIZE);
if (dir_state->cnt && dir_state->cnt % DE_STATE_CHUNK_SIZE == 0) {
jump = dir_state->cnt / DE_STATE_CHUNK_SIZE;
for (i = 0; i < jump; i++) {
store = store->next;
}
if (store == NULL) {
store = DeStateStoreAlloc();
if (store != NULL) {
dir_state->tail->next = store;
@ -147,14 +151,15 @@ static void DeStateSignatureAppend(DetectEngineState *state,
}
}
}
if (store == NULL)
SCReturn;
return;
SigIntId idx = dir_state->cnt++ % DE_STATE_CHUNK_SIZE;
store->store[idx].sid = s->num;
store->store[idx].flags = inspect_flags;
SCReturn;
return;
}
DetectEngineState *DetectEngineStateAlloc(void)

Loading…
Cancel
Save