Klaus Demo nginx / 04799a6
fix r3331: *) now pools are aligned to 16 bytes *) forbidden to set non-aligned pool sizes Igor Sysoev 11 years ago
4 changed file(s) with 15 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
286286 init_cycle.log = log;
287287 ngx_cycle = &init_cycle;
288288
289 /* dummy pagesize to create aligned pool */
290 ngx_pagesize = 1024;
291
292289 init_cycle.pool = ngx_create_pool(1024, log);
293290 if (init_cycle.pool == NULL) {
294291 return 1;
1616 {
1717 ngx_pool_t *p;
1818
19 p = ngx_memalign(ngx_min(ngx_pagesize, size), size, log);
19 p = ngx_memalign(NGX_POOL_ALIGNMENT, size, log);
2020 if (p == NULL) {
2121 return NULL;
2222 }
180180
181181 psize = (size_t) (pool->d.end - (u_char *) pool);
182182
183 m = ngx_memalign(ngx_min(ngx_pagesize, psize), psize, pool->log);
183 m = ngx_memalign(NGX_POOL_ALIGNMENT, psize, pool->log);
184184 if (m == NULL) {
185185 return NULL;
186186 }
1818 #define NGX_MAX_ALLOC_FROM_POOL (ngx_pagesize - 1)
1919
2020 #define NGX_DEFAULT_POOL_SIZE (16 * 1024)
21
22 #define NGX_POOL_ALIGNMENT 16
2123 #define NGX_MIN_POOL_SIZE \
22 (sizeof(ngx_pool_t) + 2 * sizeof(ngx_pool_large_t))
24 ngx_align((sizeof(ngx_pool_t) + 2 * sizeof(ngx_pool_large_t)), \
25 NGX_POOL_ALIGNMENT)
2326
2427
2528 typedef void (*ngx_pool_cleanup_pt)(void *data);
43174317
43184318 if (*sp < NGX_MIN_POOL_SIZE) {
43194319 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
4320 "pool must be no less than %uz", NGX_MIN_POOL_SIZE);
4321
4320 "the pool size must be no less than %uz",
4321 NGX_MIN_POOL_SIZE);
43224322 return NGX_CONF_ERROR;
43234323 }
43244324
4325 if (*sp % NGX_POOL_ALIGNMENT) {
4326 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
4327 "the pool size must be a multiple of %uz",
4328 NGX_POOL_ALIGNMENT);
4329 return NGX_CONF_ERROR;
4330 }
4331
43254332 return NGX_CONF_OK;
43264333 }