Mercurial > hg > nginx-ranges
diff src/http/ngx_http.c @ 635:e67b227c8dbb default tip
Merge with current.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 25 Apr 2011 04:07:55 +0400 |
parents | 7ea1bba9a4f6 |
children |
line wrap: on
line diff
--- a/src/http/ngx_http.c +++ b/src/http/ngx_http.c @@ -26,6 +26,9 @@ static ngx_int_t ngx_http_add_address(ng static ngx_int_t ngx_http_add_server(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf, ngx_http_conf_addr_t *addr); +static char *ngx_http_merge_servers(ngx_conf_t *cf, + ngx_http_core_main_conf_t *cmcf, ngx_http_module_t *module, + ngx_uint_t ctx_index); static char *ngx_http_merge_locations(ngx_conf_t *cf, ngx_queue_t *locations, void **loc_conf, ngx_http_module_t *module, ngx_uint_t ctx_index); @@ -263,39 +266,9 @@ ngx_http_block(ngx_conf_t *cf, ngx_comma } } - for (s = 0; s < cmcf->servers.nelts; s++) { - - /* merge the server{}s' srv_conf's */ - - if (module->merge_srv_conf) { - rv = module->merge_srv_conf(cf, ctx->srv_conf[mi], - cscfp[s]->ctx->srv_conf[mi]); - if (rv != NGX_CONF_OK) { - goto failed; - } - } - - if (module->merge_loc_conf) { - - /* merge the server{}'s loc_conf */ - - rv = module->merge_loc_conf(cf, ctx->loc_conf[mi], - cscfp[s]->ctx->loc_conf[mi]); - if (rv != NGX_CONF_OK) { - goto failed; - } - - /* merge the locations{}' loc_conf's */ - - clcf = cscfp[s]->ctx->loc_conf[ngx_http_core_module.ctx_index]; - - rv = ngx_http_merge_locations(cf, clcf->locations, - cscfp[s]->ctx->loc_conf, - module, mi); - if (rv != NGX_CONF_OK) { - goto failed; - } - } + rv = ngx_http_merge_servers(cf, cmcf, module, mi); + if (rv != NGX_CONF_OK) { + goto failed; } } @@ -509,7 +482,7 @@ ngx_http_init_phase_handlers(ngx_conf_t if (cmcf->phase_engine.server_rewrite_index == (ngx_uint_t) -1) { cmcf->phase_engine.server_rewrite_index = n; } - checker = ngx_http_core_generic_phase; + checker = ngx_http_core_rewrite_phase; break; @@ -526,7 +499,7 @@ ngx_http_init_phase_handlers(ngx_conf_t if (cmcf->phase_engine.location_rewrite_index == (ngx_uint_t) -1) { cmcf->phase_engine.location_rewrite_index = n; } - checker = ngx_http_core_generic_phase; + checker = ngx_http_core_rewrite_phase; break; @@ -586,11 +559,74 @@ ngx_http_init_phase_handlers(ngx_conf_t static char * +ngx_http_merge_servers(ngx_conf_t *cf, ngx_http_core_main_conf_t *cmcf, + ngx_http_module_t *module, ngx_uint_t ctx_index) +{ + char *rv; + ngx_uint_t s; + ngx_http_conf_ctx_t *ctx, saved; + ngx_http_core_loc_conf_t *clcf; + ngx_http_core_srv_conf_t **cscfp; + + cscfp = cmcf->servers.elts; + ctx = (ngx_http_conf_ctx_t *) cf->ctx; + saved = *ctx; + rv = NGX_CONF_OK; + + for (s = 0; s < cmcf->servers.nelts; s++) { + + /* merge the server{}s' srv_conf's */ + + ctx->srv_conf = cscfp[s]->ctx->srv_conf; + + if (module->merge_srv_conf) { + rv = module->merge_srv_conf(cf, saved.srv_conf[ctx_index], + cscfp[s]->ctx->srv_conf[ctx_index]); + if (rv != NGX_CONF_OK) { + goto failed; + } + } + + if (module->merge_loc_conf) { + + /* merge the server{}'s loc_conf */ + + ctx->loc_conf = cscfp[s]->ctx->loc_conf; + + rv = module->merge_loc_conf(cf, saved.loc_conf[ctx_index], + cscfp[s]->ctx->loc_conf[ctx_index]); + if (rv != NGX_CONF_OK) { + goto failed; + } + + /* merge the locations{}' loc_conf's */ + + clcf = cscfp[s]->ctx->loc_conf[ngx_http_core_module.ctx_index]; + + rv = ngx_http_merge_locations(cf, clcf->locations, + cscfp[s]->ctx->loc_conf, + module, ctx_index); + if (rv != NGX_CONF_OK) { + goto failed; + } + } + } + +failed: + + *ctx = saved; + + return rv; +} + + +static char * ngx_http_merge_locations(ngx_conf_t *cf, ngx_queue_t *locations, void **loc_conf, ngx_http_module_t *module, ngx_uint_t ctx_index) { char *rv; ngx_queue_t *q; + ngx_http_conf_ctx_t *ctx, saved; ngx_http_core_loc_conf_t *clcf; ngx_http_location_queue_t *lq; @@ -598,6 +634,9 @@ ngx_http_merge_locations(ngx_conf_t *cf, return NGX_CONF_OK; } + ctx = (ngx_http_conf_ctx_t *) cf->ctx; + saved = *ctx; + for (q = ngx_queue_head(locations); q != ngx_queue_sentinel(locations); q = ngx_queue_next(q)) @@ -605,6 +644,7 @@ ngx_http_merge_locations(ngx_conf_t *cf, lq = (ngx_http_location_queue_t *) q; clcf = lq->exact ? lq->exact : lq->inclusive; + ctx->loc_conf = clcf->loc_conf; rv = module->merge_loc_conf(cf, loc_conf[ctx_index], clcf->loc_conf[ctx_index]); @@ -619,6 +659,8 @@ ngx_http_merge_locations(ngx_conf_t *cf, } } + *ctx = saved; + return NGX_CONF_OK; } @@ -1179,6 +1221,9 @@ ngx_http_add_addresses(ngx_conf_t *cf, n #if (NGX_HAVE_UNIX_DOMAIN) struct sockaddr_un *saun; #endif +#if (NGX_HTTP_SSL) + ngx_uint_t ssl; +#endif /* * we can not compare whole sockaddr struct's as kernel @@ -1228,6 +1273,10 @@ ngx_http_add_addresses(ngx_conf_t *cf, n /* preserve default_server bit during listen options overwriting */ default_server = addr[i].opt.default_server; +#if (NGX_HTTP_SSL) + ssl = lsopt->ssl || addr[i].opt.ssl; +#endif + if (lsopt->set) { if (addr[i].opt.set) { @@ -1254,6 +1303,9 @@ ngx_http_add_addresses(ngx_conf_t *cf, n } addr[i].opt.default_server = default_server; +#if (NGX_HTTP_SSL) + addr[i].opt.ssl = ssl; +#endif return NGX_OK; } @@ -1450,7 +1502,7 @@ ngx_http_server_names(ngx_conf_t *cf, ng } if (rc == NGX_BUSY) { - ngx_log_error(NGX_LOG_WARN, cf->log, 0, + ngx_log_error(NGX_LOG_WARN, cf->log, 0, "conflicting server name \"%V\" on %s, ignored", &name[n].name, addr->opt.addr); } @@ -1720,6 +1772,10 @@ ngx_http_add_listening(ngx_conf_t *cf, n ls->ipv6only = addr->opt.ipv6only; #endif +#if (NGX_HAVE_SETFIB) + ls->setfib = addr->opt.setfib; +#endif + return ls; } @@ -1814,8 +1870,12 @@ ngx_http_add_addrs6(ngx_conf_t *cf, ngx_ if (addr[i].hash.buckets == NULL && (addr[i].wc_head == NULL || addr[i].wc_head->hash.buckets == NULL) - && (addr[i].wc_head == NULL - || addr[i].wc_head->hash.buckets == NULL)) + && (addr[i].wc_tail == NULL + || addr[i].wc_tail->hash.buckets == NULL) +#if (NGX_PCRE) + && addr[i].nregex == 0 +#endif + ) { continue; }