Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2005-12-26 20:07:48 +0300
committerIgor Sysoev <igor@sysoev.ru>2005-12-26 20:07:48 +0300
commit305a9d83cfba0d0330bd12af4ca56943b10e958e (patch)
tree8dc3ead91f77a4ae8953f289f57ff49b4ce9c9f1 /src/http/ngx_http_core_module.c
parentf9cbecc16a9851e8403bf7dae96feebf63b1ac3e (diff)
nginx-0.3.18-RELEASE importrelease-0.3.18
*) Feature: the "server_names" directive supports the ".domain.tld" names. *) Feature: the "server_names" directive uses the hash for the "*.domain.tld" names and more effective hash for usual names. *) Change: the "server_names_hash_max_size" and "server_names_hash_bucket_size" directives. *) Change: the "server_names_hash" and "server_names_hash_threshold" directives were canceled. *) Feature: the "valid_referers" directive uses the hash site names. *) Change: now the "valid_referers" directive checks the site names only without the URI part. *) Bugfix: some ".domain.tld" names incorrectly processed by the ngx_http_map_module. *) Bugfix: segmentation fault was occurred if configuration file did not exist; the bug had appeared in 0.3.12. *) Bugfix: on 64-bit platforms segmentation fault may occurred on start; the bug had appeared in 0.3.16.
Diffstat (limited to 'src/http/ngx_http_core_module.c')
-rw-r--r--src/http/ngx_http_core_module.c107
1 files changed, 57 insertions, 50 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index e42023b1f..4fa910390 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -73,18 +73,18 @@ static ngx_conf_enum_t ngx_http_restrict_host_names[] = {
static ngx_command_t ngx_http_core_commands[] = {
- { ngx_string("server_names_hash"),
+ { ngx_string("server_names_hash_max_size"),
NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
NGX_HTTP_MAIN_CONF_OFFSET,
- offsetof(ngx_http_core_main_conf_t, server_names_hash),
+ offsetof(ngx_http_core_main_conf_t, server_names_hash_max_size),
NULL },
- { ngx_string("server_names_hash_threshold"),
+ { ngx_string("server_names_hash_bucket_size"),
NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
NGX_HTTP_MAIN_CONF_OFFSET,
- offsetof(ngx_http_core_main_conf_t, server_names_hash_threshold),
+ offsetof(ngx_http_core_main_conf_t, server_names_hash_bucket_size),
NULL },
{ ngx_string("server"),
@@ -1715,8 +1715,8 @@ ngx_http_core_create_main_conf(ngx_conf_t *cf)
return NGX_CONF_ERROR;
}
- cmcf->server_names_hash = NGX_CONF_UNSET_UINT;
- cmcf->server_names_hash_threshold = NGX_CONF_UNSET_UINT;
+ cmcf->server_names_hash_max_size = NGX_CONF_UNSET_UINT;
+ cmcf->server_names_hash_bucket_size = NGX_CONF_UNSET_UINT;
return cmcf;
}
@@ -1727,14 +1727,17 @@ ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf)
{
ngx_http_core_main_conf_t *cmcf = conf;
- if (cmcf->server_names_hash == NGX_CONF_UNSET_UINT) {
- cmcf->server_names_hash = 1009;
+ if (cmcf->server_names_hash_max_size == NGX_CONF_UNSET_UINT) {
+ cmcf->server_names_hash_max_size = 512;
}
- if (cmcf->server_names_hash_threshold == NGX_CONF_UNSET_UINT) {
- cmcf->server_names_hash_threshold = 50;
+ if (cmcf->server_names_hash_bucket_size == NGX_CONF_UNSET_UINT) {
+ cmcf->server_names_hash_bucket_size = ngx_cacheline_size;
}
+ cmcf->server_names_hash_bucket_size =
+ ngx_align(cmcf->server_names_hash_bucket_size, ngx_cacheline_size);
+
return NGX_CONF_OK;
}
@@ -1756,19 +1759,20 @@ ngx_http_core_create_srv_conf(ngx_conf_t *cf)
*/
if (ngx_array_init(&cscf->locations, cf->pool, 4, sizeof(void *))
- == NGX_ERROR)
+ == NGX_ERROR)
{
return NGX_CONF_ERROR;
}
if (ngx_array_init(&cscf->listen, cf->pool, 4, sizeof(ngx_http_listen_t))
- == NGX_ERROR)
+ == NGX_ERROR)
{
return NGX_CONF_ERROR;
}
if (ngx_array_init(&cscf->server_names, cf->pool, 4,
- sizeof(ngx_http_server_name_t)) == NGX_ERROR)
+ sizeof(ngx_http_server_name_t))
+ == NGX_ERROR)
{
return NGX_CONF_ERROR;
}
@@ -1790,9 +1794,8 @@ ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_http_core_srv_conf_t *prev = parent;
ngx_http_core_srv_conf_t *conf = child;
- ngx_http_listen_t *ls;
- ngx_http_server_name_t *sn;
- ngx_http_core_main_conf_t *cmcf;
+ ngx_http_listen_t *ls;
+ ngx_http_server_name_t *sn;
/* TODO: it does not merge, it inits only */
@@ -1837,13 +1840,6 @@ ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
sn->name.len = ngx_strlen(sn->name.data);
sn->core_srv_conf = conf;
- sn->wildcard = 0;
-
- cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
-
- if (cmcf->max_server_name_len < sn->name.len) {
- cmcf->max_server_name_len = sn->name.len;
- }
}
ngx_conf_merge_size_value(conf->connection_pool_size,
@@ -2279,49 +2275,60 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
static char *
ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
- ngx_http_core_srv_conf_t *scf = conf;
-
- ngx_uint_t i;
- ngx_str_t *value;
- ngx_http_server_name_t *sn;
- ngx_http_core_main_conf_t *cmcf;
-
- /* TODO: warn about duplicate 'server_name' directives */
+ ngx_http_core_srv_conf_t *cscf = conf;
- cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
+ u_char ch;
+ ngx_str_t *value, name;
+ ngx_uint_t i;
+ ngx_http_server_name_t *sn;
value = cf->args->elts;
- for (i = 1; i < cf->args->nelts; i++) {
- if (value[i].len == 0) {
+ ch = value[1].data[0];
+
+ if (cscf->server_name.data == NULL && value[1].len) {
+ if (ch == '*') {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
- "server name \"%V\" is invalid "
- "in \"%V\" directive",
- &value[i], &cmd->name);
+ "first server name \"%V\" must not be wildcard",
+ &value[1]);
return NGX_CONF_ERROR;
}
- sn = ngx_array_push(&scf->server_names);
- if (sn == NULL) {
+ name = value[1];
+
+ if (ch == '.') {
+ name.len--;
+ name.data++;
+ }
+
+ cscf->server_name.len = name.len;
+ cscf->server_name.data = ngx_pstrdup(cf->pool, &name);
+ if (cscf->server_name.data == NULL) {
return NGX_CONF_ERROR;
}
+ }
- sn->name.len = value[i].len;
- sn->name.data = value[i].data;
- sn->core_srv_conf = scf;
+ for (i = 1; i < cf->args->nelts; i++) {
- if (sn->name.data[0] == '*') {
- sn->name.len--;
- sn->name.data++;
- sn->wildcard = 1;
+ ch = value[i].data[0];
- } else {
- sn->wildcard = 0;
+ if (value[i].len == 0
+ || (ch == '*' && (value[i].len < 3 || value[i].data[1] != '.'))
+ || (ch == '.' && value[i].len < 2))
+ {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "server name \"%V\" is invalid", &value[i]);
+ return NGX_CONF_ERROR;
}
- if (cmcf->max_server_name_len < sn->name.len) {
- cmcf->max_server_name_len = sn->name.len;
+ sn = ngx_array_push(&cscf->server_names);
+ if (sn == NULL) {
+ return NGX_CONF_ERROR;
}
+
+ sn->name.len = value[i].len;
+ sn->name.data = value[i].data;
+ sn->core_srv_conf = cscf;
}
return NGX_CONF_OK;