@ -173,28 +173,29 @@ void FlowSparePoolUpdate(uint32_t size)
{
{
const int64_t todo = ( int64_t ) flow_config . prealloc - ( int64_t ) size ;
const int64_t todo = ( int64_t ) flow_config . prealloc - ( int64_t ) size ;
if ( todo < 0 ) {
if ( todo < 0 ) {
/* remove one block at most at a time */
uint32_t to_remove = ( uint32_t ) ( todo * - 1 ) / 10 ;
uint32_t to_remove = ( uint32_t ) ( todo * - 1 ) / 10 ;
if ( to_remove < flow_spare_pool_block_size )
while ( to_remove ) {
return ;
if ( to_remove < flow_spare_pool_block_size )
return ;
FlowSparePool * p = NULL ;
FlowSparePool * p = NULL ;
SCMutexLock ( & flow_spare_pool_m ) ;
SCMutexLock ( & flow_spare_pool_m ) ;
p = flow_spare_pool ;
p = flow_spare_pool ;
if ( p ! = NULL ) {
if ( p ! = NULL ) {
flow_spare_pool = p - > next ;
flow_spare_pool = p - > next ;
flow_spare_pool_flow_cnt - = p - > queue . len ;
flow_spare_pool_flow_cnt - = p - > queue . len ;
}
to_remove - = p - > queue . len ;
SCMutexUnlock ( & flow_spare_pool_m ) ;
}
SCMutexUnlock ( & flow_spare_pool_m ) ;
if ( p ! = NULL ) {
if ( p ! = NULL ) {
Flow * f ;
Flow * f ;
while ( ( f = FlowQueuePrivateGetFromTop ( & p - > queue ) ) ) {
while ( ( f = FlowQueuePrivateGetFromTop ( & p - > queue ) ) ) {
FlowFree ( f ) ;
FlowFree ( f ) ;
}
SCFree ( p ) ;
}
}
SCFree ( p ) ;
}
}
} else if ( todo > 0 ) {
} else if ( todo > 0 ) {
FlowSparePool * head = NULL , * tail = NULL ;
FlowSparePool * head = NULL , * tail = NULL ;