try to reuse last 4 free large allocation links

this fixes a pool growing for multi-requests keepalive connections
This commit is contained in:
Igor Sysoev 2009-06-03 13:57:28 +00:00
parent 9af0c95f64
commit 5a2898f2b4

View File

@ -214,6 +214,7 @@ static void *
ngx_palloc_large(ngx_pool_t *pool, size_t size)
{
void *p;
ngx_uint_t n;
ngx_pool_large_t *large;
p = ngx_alloc(size, pool->log);
@ -221,6 +222,19 @@ ngx_palloc_large(ngx_pool_t *pool, size_t size)
return NULL;
}
n = 0;
for (large = pool->large; large; large = large->next) {
if (large->alloc == NULL) {
large->alloc = p;
return p;
}
if (n++ > 3) {
break;
}
}
large = ngx_palloc(pool, sizeof(ngx_pool_large_t));
if (large == NULL) {
ngx_free(p);