Mercurial > hg > nginx
comparison src/http/ngx_http_request.c @ 5089:903f2a5d86a5
SNI: reuse selected configuration for all requests in a connection.
Previously, only the first request in a connection was assigned the
configuration selected by SNI. All subsequent requests initially
used the default server's configuration, ignoring SNI, which was
wrong.
Now all subsequent requests in a connection will initially use the
configuration selected by SNI. This is done by storing a pointer
to configuration in http connection object. It points to default
server's configuration initially, but changed upon receipt of SNI.
(The request's configuration can be further refined when parsing
the request line and Host: header.)
This change was not made specific to SNI as it also allows slightly
faster access to configuration without the request object.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Wed, 27 Feb 2013 17:12:48 +0000 |
parents | ac31fcecb464 |
children | 9db95b275755 |
comparison
equal
deleted
inserted
replaced
5088:ac31fcecb464 | 5089:903f2a5d86a5 |
---|---|
290 hc->addr_conf = &addr[0].conf; | 290 hc->addr_conf = &addr[0].conf; |
291 break; | 291 break; |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 /* the default server configuration for the address:port */ | |
296 hc->conf_ctx = hc->addr_conf->default_server->ctx; | |
297 | |
295 ctx = ngx_palloc(c->pool, sizeof(ngx_http_log_ctx_t)); | 298 ctx = ngx_palloc(c->pool, sizeof(ngx_http_log_ctx_t)); |
296 if (ctx == NULL) { | 299 if (ctx == NULL) { |
297 ngx_http_close_connection(c); | 300 ngx_http_close_connection(c); |
298 return; | 301 return; |
299 } | 302 } |
397 c->sent = 0; | 400 c->sent = 0; |
398 r->signature = NGX_HTTP_MODULE; | 401 r->signature = NGX_HTTP_MODULE; |
399 | 402 |
400 r->connection = c; | 403 r->connection = c; |
401 | 404 |
402 /* the default server configuration for the address:port */ | 405 r->main_conf = hc->conf_ctx->main_conf; |
403 cscf = hc->addr_conf->default_server; | 406 r->srv_conf = hc->conf_ctx->srv_conf; |
404 | 407 r->loc_conf = hc->conf_ctx->loc_conf; |
405 r->main_conf = cscf->ctx->main_conf; | |
406 r->srv_conf = cscf->ctx->srv_conf; | |
407 r->loc_conf = cscf->ctx->loc_conf; | |
408 | 408 |
409 rev->handler = ngx_http_process_request_line; | 409 rev->handler = ngx_http_process_request_line; |
410 r->read_event_handler = ngx_http_block_reading; | 410 r->read_event_handler = ngx_http_block_reading; |
411 | 411 |
412 #if (NGX_HTTP_SSL) | 412 #if (NGX_HTTP_SSL) |
446 #endif | 446 #endif |
447 | 447 |
448 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 448 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
449 | 449 |
450 ngx_http_set_connection_log(r->connection, clcf->error_log); | 450 ngx_http_set_connection_log(r->connection, clcf->error_log); |
451 | |
452 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | |
451 | 453 |
452 if (c->buffer == NULL) { | 454 if (c->buffer == NULL) { |
453 c->buffer = ngx_create_temp_buf(c->pool, | 455 c->buffer = ngx_create_temp_buf(c->pool, |
454 cscf->client_header_buffer_size); | 456 cscf->client_header_buffer_size); |
455 if (c->buffer == NULL) { | 457 if (c->buffer == NULL) { |
686 NULL, &cscf) | 688 NULL, &cscf) |
687 != NGX_OK) | 689 != NGX_OK) |
688 { | 690 { |
689 return SSL_TLSEXT_ERR_NOACK; | 691 return SSL_TLSEXT_ERR_NOACK; |
690 } | 692 } |
693 | |
694 hc->conf_ctx = cscf->ctx; | |
691 | 695 |
692 r->srv_conf = cscf->ctx->srv_conf; | 696 r->srv_conf = cscf->ctx->srv_conf; |
693 r->loc_conf = cscf->ctx->loc_conf; | 697 r->loc_conf = cscf->ctx->loc_conf; |
694 | 698 |
695 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 699 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |