diff options
author | Igor Sysoev <igor@sysoev.ru> | 2009-06-03 17:57:28 +0400 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2009-06-03 17:57:28 +0400 |
commit | 5a2898f2b4c38dc6d199a459b06c3cd51a11ea7b (patch) | |
tree | ee72e5f5f99e33642b8e1d96613c8a76ed70e59a /src | |
parent | 9af0c95f64d384b97c7ae9fd43f0ff0acf57831c (diff) |
try to reuse last 4 free large allocation links
this fixes a pool growing for multi-requests keepalive connections
Diffstat (limited to 'src')
-rw-r--r-- | src/core/ngx_palloc.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/ngx_palloc.c b/src/core/ngx_palloc.c index 3e1c9f2ad..a3f73f45e 100644 --- a/src/core/ngx_palloc.c +++ b/src/core/ngx_palloc.c @@ -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); |