# HG changeset patch # User Igor Sysoev # Date 1244208432 0 # Node ID cb7d05c097dbebfb3213d9f28fcb2c13a1679ee9 # Parent 41e7d9153967c99dc0a5030fbca2218119eec79f do not test a pool block space if we can not allocated from the block 4 times diff --git a/src/core/ngx_palloc.c b/src/core/ngx_palloc.c --- a/src/core/ngx_palloc.c +++ b/src/core/ngx_palloc.c @@ -25,6 +25,7 @@ ngx_create_pool(size_t size, ngx_log_t * p->d.last = (u_char *) p + sizeof(ngx_pool_t); p->d.end = (u_char *) p + size; p->d.next = NULL; + p->d.failed = 0; size = size - sizeof(ngx_pool_t); p->max = (size < NGX_MAX_ALLOC_FROM_POOL) ? size : NGX_MAX_ALLOC_FROM_POOL; @@ -189,6 +190,7 @@ ngx_palloc_block(ngx_pool_t *pool, size_ new->d.end = m + psize; new->d.next = NULL; + new->d.failed = 0; m += sizeof(ngx_pool_data_t); m = ngx_align_ptr(m, NGX_ALIGNMENT); @@ -197,7 +199,7 @@ ngx_palloc_block(ngx_pool_t *pool, size_ current = pool->current; for (p = current; p->d.next; p = p->d.next) { - if ((size_t) (p->d.end - p->d.last) < NGX_ALIGNMENT) { + if (p->d.failed++ > 4) { current = p->d.next; } } diff --git a/src/core/ngx_palloc.h b/src/core/ngx_palloc.h --- a/src/core/ngx_palloc.h +++ b/src/core/ngx_palloc.h @@ -46,6 +46,7 @@ typedef struct { u_char *last; u_char *end; ngx_pool_t *next; + ngx_uint_t failed; } ngx_pool_data_t;