Mercurial > hg > nginx
comparison src/http/ngx_http_core_module.c @ 2377:87b8c44906b5
*) refactor subrequest handling, now they run as separate posted requests
*) now $upstream_addr, $upstream_status, $upstream_response_time can be used
with log_subrequest
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 08 Dec 2008 14:23:20 +0000 |
parents | c59485781f0a |
children | 2c2b79633ded |
comparison
equal
deleted
inserted
replaced
2376:29d89920a749 | 2377:87b8c44906b5 |
---|---|
1829 ngx_str_t *uri, ngx_str_t *args, ngx_http_request_t **psr, | 1829 ngx_str_t *uri, ngx_str_t *args, ngx_http_request_t **psr, |
1830 ngx_http_post_subrequest_t *ps, ngx_uint_t flags) | 1830 ngx_http_post_subrequest_t *ps, ngx_uint_t flags) |
1831 { | 1831 { |
1832 ngx_connection_t *c; | 1832 ngx_connection_t *c; |
1833 ngx_http_request_t *sr; | 1833 ngx_http_request_t *sr; |
1834 ngx_http_log_ctx_t *ctx; | |
1835 ngx_http_core_srv_conf_t *cscf; | 1834 ngx_http_core_srv_conf_t *cscf; |
1836 ngx_http_postponed_request_t *pr, *p; | 1835 ngx_http_postponed_request_t *pr, *p; |
1837 | 1836 |
1838 r->main->subrequests--; | 1837 r->main->subrequests--; |
1839 | 1838 |
1894 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | 1893 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
1895 "http subrequest \"%V?%V\"", uri, &sr->args); | 1894 "http subrequest \"%V?%V\"", uri, &sr->args); |
1896 | 1895 |
1897 sr->zero_in_uri = (flags & NGX_HTTP_ZERO_IN_URI) != 0; | 1896 sr->zero_in_uri = (flags & NGX_HTTP_ZERO_IN_URI) != 0; |
1898 sr->subrequest_in_memory = (flags & NGX_HTTP_SUBREQUEST_IN_MEMORY) != 0; | 1897 sr->subrequest_in_memory = (flags & NGX_HTTP_SUBREQUEST_IN_MEMORY) != 0; |
1898 sr->waited = (flags & NGX_HTTP_SUBREQUEST_WAITED) != 0; | |
1899 | 1899 |
1900 sr->unparsed_uri = r->unparsed_uri; | 1900 sr->unparsed_uri = r->unparsed_uri; |
1901 sr->method_name = ngx_http_core_get_method; | 1901 sr->method_name = ngx_http_core_get_method; |
1902 sr->http_protocol = r->http_protocol; | 1902 sr->http_protocol = r->http_protocol; |
1903 | 1903 |
1907 | 1907 |
1908 sr->main = r->main; | 1908 sr->main = r->main; |
1909 sr->parent = r; | 1909 sr->parent = r; |
1910 sr->post_subrequest = ps; | 1910 sr->post_subrequest = ps; |
1911 sr->read_event_handler = ngx_http_request_empty_handler; | 1911 sr->read_event_handler = ngx_http_request_empty_handler; |
1912 sr->write_event_handler = ngx_http_request_empty_handler; | 1912 sr->write_event_handler = ngx_http_handler; |
1913 | 1913 |
1914 if (c->data == r) { | 1914 if (c->data == r) { |
1915 c->data = sr; | 1915 c->data = sr; |
1916 } | 1916 } |
1917 | 1917 |
1938 | 1938 |
1939 } else { | 1939 } else { |
1940 r->postponed = pr; | 1940 r->postponed = pr; |
1941 } | 1941 } |
1942 | 1942 |
1943 ctx = c->log->data; | |
1944 ctx->current_request = sr; | |
1945 | |
1946 sr->internal = 1; | 1943 sr->internal = 1; |
1947 sr->fast_subrequest = 1; | |
1948 | 1944 |
1949 sr->discard_body = r->discard_body; | 1945 sr->discard_body = r->discard_body; |
1950 sr->main_filter_need_in_memory = r->main_filter_need_in_memory; | 1946 sr->main_filter_need_in_memory = r->main_filter_need_in_memory; |
1951 | 1947 |
1952 sr->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1; | 1948 sr->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1; |
1953 | 1949 |
1954 ngx_http_handler(sr); | 1950 r->main->subrequests++; |
1955 | 1951 |
1956 if (!c->destroyed) { | 1952 *psr = sr; |
1957 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | 1953 |
1958 "http subrequest done \"%V?%V\"", uri, &sr->args); | 1954 return ngx_http_post_request(sr); |
1959 | |
1960 r->main->subrequests++; | |
1961 | |
1962 *psr = sr; | |
1963 | |
1964 if (sr->fast_subrequest) { | |
1965 sr->fast_subrequest = 0; | |
1966 | |
1967 if (sr->done) { | |
1968 return NGX_OK; | |
1969 } | |
1970 } | |
1971 | |
1972 return NGX_AGAIN; | |
1973 } | |
1974 | |
1975 return NGX_DONE; | |
1976 } | 1955 } |
1977 | 1956 |
1978 | 1957 |
1979 ngx_int_t | 1958 ngx_int_t |
1980 ngx_http_internal_redirect(ngx_http_request_t *r, | 1959 ngx_http_internal_redirect(ngx_http_request_t *r, |