Fix flow engine memory handling.

remotes/origin/master-1.0.x
Victor Julien 15 years ago
parent 4dd0169499
commit 3484e2abde

@ -36,8 +36,6 @@
#include "detect.h"
#include "detect-engine-state.h"
/* Counter of flows that reached memcap capability */
uint32_t directflows = 0;
/* Allocate a flow */
Flow *FlowAlloc(void)
@ -45,11 +43,18 @@ Flow *FlowAlloc(void)
Flow *f;
SCMutexLock(&flow_memuse_mutex);
if (flow_memuse + sizeof(Flow) > flow_config.memcap) {
SCMutexUnlock(&flow_memuse_mutex);
return NULL;
}
SCMutexUnlock(&flow_memuse_mutex);
f = SCMalloc(sizeof(Flow));
if (f == NULL) {
SCMutexUnlock(&flow_memuse_mutex);
return NULL;
}
SCMutexLock(&flow_memuse_mutex);
flow_memuse += sizeof(Flow);
SCMutexUnlock(&flow_memuse_mutex);
@ -59,9 +64,6 @@ Flow *FlowAlloc(void)
f->hnext = NULL;
f->hprev = NULL;
f->flowvar = NULL;
f->de_state = NULL;
return f;
}
@ -104,6 +106,7 @@ void FlowInit(Flow *f, Packet *p)
SCEnter();
SCLogDebug("flow %p", f);
f->flowvar = NULL;
f->de_state = NULL;
CLEAR_FLOW(f);

@ -269,7 +269,7 @@ static uint32_t FlowPruneFlowQueue(FlowQueue *q, struct timeval *ts)
{
SCEnter();
uint32_t cnt = 0;
//while(FlowPrune(q, ts)) { cnt++; }
while(FlowPrune(q, ts)) { cnt++; }
return cnt;
}
@ -1312,9 +1312,9 @@ static int FlowClearMemory(Flow* f, uint8_t proto_map) {
if (flow_proto[proto_map].Freefunc != NULL) {
flow_proto[proto_map].Freefunc(f->protoctx);
}
f->protoctx = NULL;
CLEAR_FLOW(f);
SCReturnInt(1);
}

@ -701,7 +701,8 @@ uint32_t UTHBuildPacketOfFlows(uint32_t start, uint32_t end, uint8_t dir) {
p->dst.addr_data32[0] = i;
}
FlowHandlePacket(NULL, p);
p->flow->use_cnt = 0;
if (p->flow != NULL)
p->flow->use_cnt = 0;
/* Now the queues shoul be updated */
UTHFreePacket(p);

Loading…
Cancel
Save