diff options
author | Igor Sysoev <igor@sysoev.ru> | 2009-12-17 12:25:46 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2009-12-17 12:25:46 +0000 |
commit | 04799a6f7c69c525969255a3bf5acaa4959552d4 (patch) | |
tree | 66be6a0caa6ca245b1c1002cfd8bb006264ab65f /src | |
parent | a75362dcdbd5d8d911ddf135f71b3be68ce5ef31 (diff) | |
download | nginx-04799a6f7c69c525969255a3bf5acaa4959552d4.tar.gz nginx-04799a6f7c69c525969255a3bf5acaa4959552d4.zip |
fix r3331:
*) now pools are aligned to 16 bytes
*) forbidden to set non-aligned pool sizes
Diffstat (limited to 'src')
-rw-r--r-- | src/core/nginx.c | 3 | ||||
-rw-r--r-- | src/core/ngx_palloc.c | 4 | ||||
-rw-r--r-- | src/core/ngx_palloc.h | 5 | ||||
-rw-r--r-- | src/http/ngx_http_core_module.c | 9 |
4 files changed, 14 insertions, 7 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index 7387aa1ba..5df96a438 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -287,9 +287,6 @@ main(int argc, char *const *argv) init_cycle.log = log; ngx_cycle = &init_cycle; - /* dummy pagesize to create aligned pool */ - ngx_pagesize = 1024; - init_cycle.pool = ngx_create_pool(1024, log); if (init_cycle.pool == NULL) { return 1; diff --git a/src/core/ngx_palloc.c b/src/core/ngx_palloc.c index 7db0d7da4..35f13119c 100644 --- a/src/core/ngx_palloc.c +++ b/src/core/ngx_palloc.c @@ -17,7 +17,7 @@ ngx_create_pool(size_t size, ngx_log_t *log) { ngx_pool_t *p; - p = ngx_memalign(ngx_min(ngx_pagesize, size), size, log); + p = ngx_memalign(NGX_POOL_ALIGNMENT, size, log); if (p == NULL) { return NULL; } @@ -181,7 +181,7 @@ ngx_palloc_block(ngx_pool_t *pool, size_t size) psize = (size_t) (pool->d.end - (u_char *) pool); - m = ngx_memalign(ngx_min(ngx_pagesize, psize), psize, pool->log); + m = ngx_memalign(NGX_POOL_ALIGNMENT, psize, pool->log); if (m == NULL) { return NULL; } diff --git a/src/core/ngx_palloc.h b/src/core/ngx_palloc.h index 7706df19c..6e6612cca 100644 --- a/src/core/ngx_palloc.h +++ b/src/core/ngx_palloc.h @@ -19,8 +19,11 @@ #define NGX_MAX_ALLOC_FROM_POOL (ngx_pagesize - 1) #define NGX_DEFAULT_POOL_SIZE (16 * 1024) + +#define NGX_POOL_ALIGNMENT 16 #define NGX_MIN_POOL_SIZE \ - (sizeof(ngx_pool_t) + 2 * sizeof(ngx_pool_large_t)) + ngx_align((sizeof(ngx_pool_t) + 2 * sizeof(ngx_pool_large_t)), \ + NGX_POOL_ALIGNMENT) typedef void (*ngx_pool_cleanup_pt)(void *data); diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 7de430bc4..e05487ee2 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -4318,8 +4318,15 @@ ngx_http_core_pool_size(ngx_conf_t *cf, void *post, void *data) if (*sp < NGX_MIN_POOL_SIZE) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "pool must be no less than %uz", NGX_MIN_POOL_SIZE); + "the pool size must be no less than %uz", + NGX_MIN_POOL_SIZE); + return NGX_CONF_ERROR; + } + if (*sp % NGX_POOL_ALIGNMENT) { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "the pool size must be a multiple of %uz", + NGX_POOL_ALIGNMENT); return NGX_CONF_ERROR; } |