aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2007-11-27 11:33:52 +0000
committerIgor Sysoev <igor@sysoev.ru>2007-11-27 11:33:52 +0000
commit13f5ff9d7efce9dd9ffa4e22d6f56089a6a491f0 (patch)
tree51d7d3cc307ae8245df8e6e0ade2b8af678ef349 /src
parentb50b32e25581fa5e2c119191f237d27f42081c8a (diff)
downloadnginx-13f5ff9d7efce9dd9ffa4e22d6f56089a6a491f0.tar.gz
nginx-13f5ff9d7efce9dd9ffa4e22d6f56089a6a491f0.zip
http resolver and resolver_timeout
Diffstat (limited to 'src')
-rw-r--r--src/http/ngx_http_core_module.c50
-rw-r--r--src/http/ngx_http_core_module.h3
2 files changed, 53 insertions, 0 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 5ac187344..da0288dfa 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -69,6 +69,8 @@ static char *ngx_http_core_keepalive(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
static char *ngx_http_core_internal(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
+static char * ngx_http_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd,
+ 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);
@@ -492,6 +494,20 @@ static ngx_command_t ngx_http_core_commands[] = {
offsetof(ngx_http_core_loc_conf_t, open_file_cache_events),
NULL },
+ { ngx_string("resolver"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_http_core_resolver,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ 0,
+ NULL },
+
+ { ngx_string("resolver_timeout"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_msec_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_core_loc_conf_t, resolver_timeout),
+ NULL },
+
ngx_null_command
};
@@ -2391,6 +2407,7 @@ ngx_http_core_create_loc_conf(ngx_conf_t *cf)
lcf->keepalive_header = NGX_CONF_UNSET;
lcf->lingering_time = NGX_CONF_UNSET_MSEC;
lcf->lingering_timeout = NGX_CONF_UNSET_MSEC;
+ lcf->resolver_timeout = NGX_CONF_UNSET_MSEC;
lcf->reset_timedout_connection = NGX_CONF_UNSET;
lcf->port_in_redirect = NGX_CONF_UNSET;
lcf->msie_padding = NGX_CONF_UNSET;
@@ -2572,6 +2589,12 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
prev->lingering_time, 30000);
ngx_conf_merge_msec_value(conf->lingering_timeout,
prev->lingering_timeout, 5000);
+ ngx_conf_merge_msec_value(conf->resolver_timeout,
+ prev->resolver_timeout, 30000);
+
+ if (conf->resolver == NULL) {
+ conf->resolver = prev->resolver;
+ }
ngx_conf_merge_path_value(conf->client_body_temp_path,
prev->client_body_temp_path,
@@ -3361,6 +3384,33 @@ ngx_http_core_internal(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
static char *
+ngx_http_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+ ngx_http_core_loc_conf_t *clcf = conf;
+
+ ngx_url_t u;
+ ngx_str_t *value;
+
+ value = cf->args->elts;
+
+ u.host = value[1];
+ u.port = 53;
+
+ if (ngx_inet_resolve_host(cf->pool, &u) != NGX_OK) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%V: %s", &u.host, u.err);
+ return NGX_CONF_ERROR;
+ }
+
+ clcf->resolver = ngx_resolver_create(&u.addrs[0], cf->cycle->new_log);
+ if (clcf->resolver == NULL) {
+ return NGX_OK;
+ }
+
+ return NGX_CONF_OK;
+}
+
+
+static char *
ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data)
{
#if (NGX_FREEBSD)
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index a2f29e267..2027f511e 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -270,6 +270,9 @@ struct ngx_http_core_loc_conf_s {
ngx_msec_t keepalive_timeout; /* keepalive_timeout */
ngx_msec_t lingering_time; /* lingering_time */
ngx_msec_t lingering_timeout; /* lingering_timeout */
+ ngx_msec_t resolver_timeout; /* resolver_timeout */
+
+ ngx_resolver_t *resolver; /* resolver */
time_t keepalive_header; /* keepalive_timeout */