comparison src/core/ngx_palloc.c @ 2920:cb7d05c097db

do not test a pool block space if we can not allocated from the block 4 times
author Igor Sysoev <igor@sysoev.ru>
date Fri, 05 Jun 2009 13:27:12 +0000
parents 62010fa37ead
children adc4fc0c3cc3
comparison
equal deleted inserted replaced
2919:41e7d9153967 2920:cb7d05c097db
23 } 23 }
24 24
25 p->d.last = (u_char *) p + sizeof(ngx_pool_t); 25 p->d.last = (u_char *) p + sizeof(ngx_pool_t);
26 p->d.end = (u_char *) p + size; 26 p->d.end = (u_char *) p + size;
27 p->d.next = NULL; 27 p->d.next = NULL;
28 p->d.failed = 0;
28 29
29 size = size - sizeof(ngx_pool_t); 30 size = size - sizeof(ngx_pool_t);
30 p->max = (size < NGX_MAX_ALLOC_FROM_POOL) ? size : NGX_MAX_ALLOC_FROM_POOL; 31 p->max = (size < NGX_MAX_ALLOC_FROM_POOL) ? size : NGX_MAX_ALLOC_FROM_POOL;
31 32
32 p->current = p; 33 p->current = p;
187 188
188 new = (ngx_pool_t *) m; 189 new = (ngx_pool_t *) m;
189 190
190 new->d.end = m + psize; 191 new->d.end = m + psize;
191 new->d.next = NULL; 192 new->d.next = NULL;
193 new->d.failed = 0;
192 194
193 m += sizeof(ngx_pool_data_t); 195 m += sizeof(ngx_pool_data_t);
194 m = ngx_align_ptr(m, NGX_ALIGNMENT); 196 m = ngx_align_ptr(m, NGX_ALIGNMENT);
195 new->d.last = m + size; 197 new->d.last = m + size;
196 198
197 current = pool->current; 199 current = pool->current;
198 200
199 for (p = current; p->d.next; p = p->d.next) { 201 for (p = current; p->d.next; p = p->d.next) {
200 if ((size_t) (p->d.end - p->d.last) < NGX_ALIGNMENT) { 202 if (p->d.failed++ > 4) {
201 current = p->d.next; 203 current = p->d.next;
202 } 204 }
203 } 205 }
204 206
205 p->d.next = new; 207 p->d.next = new;