# HG changeset patch # User Igor Sysoev # Date 1178529642 0 # Node ID ff63527ea29c7d446870771383f478edbd3db692 # Parent 98317b0a0852352bc09357a7e1c5e8354d57c697 limit minimal pool size 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 @@ -19,7 +19,9 @@ */ #define NGX_MAX_ALLOC_FROM_POOL (ngx_pagesize - 1) -#define NGX_DEFAULT_POOL_SIZE (16 * 1024) +#define NGX_DEFAULT_POOL_SIZE (16 * 1024) +#define NGX_MIN_POOL_SIZE \ + (sizeof(ngx_pool_t) + 2 * sizeof(ngx_pool_large_t)) 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 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -70,10 +70,14 @@ static char *ngx_http_core_internal(ngx_ void *conf); static char *ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data); +static char *ngx_http_core_pool_size(ngx_conf_t *cf, void *post, void *data); static ngx_conf_post_t ngx_http_core_lowat_post = { ngx_http_core_lowat_check }; +static ngx_conf_post_handler_pt ngx_http_core_pool_size_p = + ngx_http_core_pool_size; + static ngx_conf_deprecated_t ngx_conf_deprecated_optimize_host_names = { ngx_conf_deprecated, "optimize_host_names", "optimize_server_names" }; @@ -129,14 +133,14 @@ static ngx_command_t ngx_http_core_comm ngx_conf_set_size_slot, NGX_HTTP_SRV_CONF_OFFSET, offsetof(ngx_http_core_srv_conf_t, connection_pool_size), - NULL }, + &ngx_http_core_pool_size_p }, { ngx_string("request_pool_size"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, ngx_conf_set_size_slot, NGX_HTTP_SRV_CONF_OFFSET, offsetof(ngx_http_core_srv_conf_t, request_pool_size), - NULL }, + &ngx_http_core_pool_size_p }, { ngx_string("client_header_timeout"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, @@ -3052,3 +3056,19 @@ ngx_http_core_lowat_check(ngx_conf_t *cf return NGX_CONF_OK; } + + +static char * +ngx_http_core_pool_size(ngx_conf_t *cf, void *post, void *data) +{ + size_t *sp = 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); + + return NGX_CONF_ERROR; + } + + return NGX_CONF_OK; +}