Removing FlowAllocDirect since it's not needed anymore

remotes/origin/master-1.0.x
Pablo Rincon 16 years ago committed by Victor Julien
parent 2fd31a1a11
commit b491ef2be0

@ -340,7 +340,7 @@ static Flow *FlowGetNew(Packet *p) {
} }
/* now see if we can alloc a new flow */ /* now see if we can alloc a new flow */
f = FlowAllocDirect(); f = FlowAlloc();
if (f == NULL) { if (f == NULL) {
return NULL; return NULL;
} }

@ -39,46 +39,12 @@
/* Counter of flows that reached memcap capability */ /* Counter of flows that reached memcap capability */
uint32_t directflows = 0; uint32_t directflows = 0;
/* Allocate a flow without checking memcap */
Flow *FlowAllocDirect(void)
{
Flow *f;
SCMutexLock(&flow_memuse_mutex);
/* We allow to alloc even if memcap is reached (but later we
* will clean up some flows */
f = SCMalloc(sizeof(Flow));
if (f == NULL) {
SCMutexUnlock(&flow_memuse_mutex);
return NULL;
}
directflows++;
flow_memuse += sizeof(Flow);
SCMutexUnlock(&flow_memuse_mutex);
//FlowPrintQueueInfo();
SCMutexInit(&f->m, NULL);
f->lnext = NULL;
f->lprev = NULL;
f->hnext = NULL;
f->hprev = NULL;
f->flowvar = NULL;
return f;
}
/* Allocate a flow */ /* Allocate a flow */
Flow *FlowAlloc(void) Flow *FlowAlloc(void)
{ {
Flow *f; Flow *f;
SCMutexLock(&flow_memuse_mutex); SCMutexLock(&flow_memuse_mutex);
if (flow_memuse + sizeof(Flow) > flow_config.memcap) {
SCMutexUnlock(&flow_memuse_mutex);
return NULL;
}
f = SCMalloc(sizeof(Flow)); f = SCMalloc(sizeof(Flow));
if (f == NULL) { if (f == NULL) {
SCMutexUnlock(&flow_memuse_mutex); SCMutexUnlock(&flow_memuse_mutex);

@ -792,8 +792,15 @@ void FlowInitConfig (char quiet)
/* pre allocate flows */ /* pre allocate flows */
for (i = 0; i < flow_config.prealloc; i++) { for (i = 0; i < flow_config.prealloc; i++) {
if (flow_memuse + sizeof(Flow) > flow_config.memcap) {
SCMutexUnlock(&flow_memuse_mutex);
printf("ERROR: FlowAlloc failed (max flow memcap reached): %s\n", strerror(errno));
exit(1);
}
Flow *f = FlowAlloc(); Flow *f = FlowAlloc();
if (f == NULL) { if (f == NULL) {
SCMutexUnlock(&flow_memuse_mutex);
printf("ERROR: FlowAlloc failed: %s\n", strerror(errno)); printf("ERROR: FlowAlloc failed: %s\n", strerror(errno));
exit(1); exit(1);
} }

Loading…
Cancel
Save