comparison src/http/modules/ngx_http_fastcgi_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 37400c84396e
comparison
equal deleted inserted replaced
3005:5bc8811728f8 3006:95972b9e790b
541 "ngx_http_fastcgi_module does not support " 541 "ngx_http_fastcgi_module does not support "
542 "subrequest in memory"); 542 "subrequest in memory");
543 return NGX_HTTP_INTERNAL_SERVER_ERROR; 543 return NGX_HTTP_INTERNAL_SERVER_ERROR;
544 } 544 }
545 545
546 if (ngx_http_upstream_create(r) != NGX_OK) {
547 return NGX_HTTP_INTERNAL_SERVER_ERROR;
548 }
549
546 f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t)); 550 f = ngx_pcalloc(r->pool, sizeof(ngx_http_fastcgi_ctx_t));
547 if (f == NULL) { 551 if (f == NULL) {
548 return NGX_ERROR; 552 return NGX_HTTP_INTERNAL_SERVER_ERROR;
549 } 553 }
550 554
551 ngx_http_set_ctx(r, f, ngx_http_fastcgi_module); 555 ngx_http_set_ctx(r, f, ngx_http_fastcgi_module);
552
553 u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t));
554 if (u == NULL) {
555 return NGX_HTTP_INTERNAL_SERVER_ERROR;
556 }
557
558 r->upstream = u;
559 556
560 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); 557 flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
561 558
562 if (flcf->fastcgi_lengths) { 559 if (flcf->fastcgi_lengths) {
563 if (ngx_http_fastcgi_eval(r, flcf) != NGX_OK) { 560 if (ngx_http_fastcgi_eval(r, flcf) != NGX_OK) {
564 return NGX_HTTP_INTERNAL_SERVER_ERROR; 561 return NGX_HTTP_INTERNAL_SERVER_ERROR;
565 } 562 }
566 } 563 }
567 564
565 u = r->upstream;
566
568 u->schema.len = sizeof("fastcgi://") - 1; 567 u->schema.len = sizeof("fastcgi://") - 1;
569 u->schema.data = (u_char *) "fastcgi://"; 568 u->schema.data = (u_char *) "fastcgi://";
570
571 u->peer.log = r->connection->log;
572 u->peer.log_error = NGX_ERROR_ERR;
573 #if (NGX_THREADS)
574 u->peer.lock = &r->connection->lock;
575 #endif
576 569
577 u->output.tag = (ngx_buf_tag_t) &ngx_http_fastcgi_module; 570 u->output.tag = (ngx_buf_tag_t) &ngx_http_fastcgi_module;
578 571
579 u->conf = &flcf->upstream; 572 u->conf = &flcf->upstream;
580 573