comparison src/http/modules/ngx_http_proxy_module.c @ 3006:95972b9e790b

ngx_http_upstream_create() to cleanup the previous upstream after internal redirect
author Igor Sysoev <igor@sysoev.ru>
date Mon, 27 Jul 2009 13:25:29 +0000
parents dff9764eaca2
children fcd98af88df3
comparison
equal deleted inserted replaced
3005:5bc8811728f8 3006:95972b9e790b
588 ngx_int_t rc; 588 ngx_int_t rc;
589 ngx_http_upstream_t *u; 589 ngx_http_upstream_t *u;
590 ngx_http_proxy_ctx_t *ctx; 590 ngx_http_proxy_ctx_t *ctx;
591 ngx_http_proxy_loc_conf_t *plcf; 591 ngx_http_proxy_loc_conf_t *plcf;
592 592
593 u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t)); 593 if (ngx_http_upstream_create(r) != NGX_OK) {
594 if (u == NULL) {
595 return NGX_HTTP_INTERNAL_SERVER_ERROR; 594 return NGX_HTTP_INTERNAL_SERVER_ERROR;
596 } 595 }
597
598 r->upstream = u;
599 596
600 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_ctx_t)); 597 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_ctx_t));
601 if (ctx == NULL) { 598 if (ctx == NULL) {
602 return NGX_ERROR; 599 return NGX_ERROR;
603 } 600 }
604 601
605 ngx_http_set_ctx(r, ctx, ngx_http_proxy_module); 602 ngx_http_set_ctx(r, ctx, ngx_http_proxy_module);
606 603
607 plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module); 604 plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module);
605
606 u = r->upstream;
608 607
609 if (plcf->proxy_lengths == 0) { 608 if (plcf->proxy_lengths == 0) {
610 ctx->vars = plcf->vars; 609 ctx->vars = plcf->vars;
611 u->schema = plcf->vars.schema; 610 u->schema = plcf->vars.schema;
612 #if (NGX_HTTP_SSL) 611 #if (NGX_HTTP_SSL)
616 } else { 615 } else {
617 if (ngx_http_proxy_eval(r, ctx, plcf) != NGX_OK) { 616 if (ngx_http_proxy_eval(r, ctx, plcf) != NGX_OK) {
618 return NGX_HTTP_INTERNAL_SERVER_ERROR; 617 return NGX_HTTP_INTERNAL_SERVER_ERROR;
619 } 618 }
620 } 619 }
621
622 u->peer.log = r->connection->log;
623 u->peer.log_error = NGX_ERROR_ERR;
624 #if (NGX_THREADS)
625 u->peer.lock = &r->connection->lock;
626 #endif
627 620
628 u->output.tag = (ngx_buf_tag_t) &ngx_http_proxy_module; 621 u->output.tag = (ngx_buf_tag_t) &ngx_http_proxy_module;
629 622
630 u->conf = &plcf->upstream; 623 u->conf = &plcf->upstream;
631 624