mirror of
https://github.com/nginx/nginx.git
synced 2024-12-05 06:19:01 +08:00
optimize r->upstream usage
This commit is contained in:
parent
86ef6aaa6b
commit
f2932dcbe5
@ -381,7 +381,7 @@ ngx_http_upstream_init(ngx_http_request_t *r)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
host = &r->upstream->resolved->host;
|
host = &u->resolved->host;
|
||||||
|
|
||||||
umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
|
umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
|
||||||
|
|
||||||
@ -840,10 +840,9 @@ ngx_http_upstream_reinit(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_memzero(&r->upstream->headers_in,
|
ngx_memzero(&u->headers_in, sizeof(ngx_http_upstream_headers_in_t));
|
||||||
sizeof(ngx_http_upstream_headers_in_t));
|
|
||||||
|
|
||||||
if (ngx_list_init(&r->upstream->headers_in.headers, r->pool, 8,
|
if (ngx_list_init(&u->headers_in.headers, r->pool, 8,
|
||||||
sizeof(ngx_table_elt_t))
|
sizeof(ngx_table_elt_t))
|
||||||
!= NGX_OK)
|
!= NGX_OK)
|
||||||
{
|
{
|
||||||
@ -1078,7 +1077,7 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
|
|||||||
|
|
||||||
u->buffer.tag = u->output.tag;
|
u->buffer.tag = u->output.tag;
|
||||||
|
|
||||||
if (ngx_list_init(&r->upstream->headers_in.headers, r->pool, 8,
|
if (ngx_list_init(&u->headers_in.headers, r->pool, 8,
|
||||||
sizeof(ngx_table_elt_t))
|
sizeof(ngx_table_elt_t))
|
||||||
!= NGX_OK)
|
!= NGX_OK)
|
||||||
{
|
{
|
||||||
@ -1247,11 +1246,11 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
|
|||||||
|
|
||||||
umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
|
umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
|
||||||
|
|
||||||
if (r->upstream->headers_in.x_accel_redirect) {
|
if (u->headers_in.x_accel_redirect) {
|
||||||
|
|
||||||
ngx_http_upstream_finalize_request(r, u, NGX_DECLINED);
|
ngx_http_upstream_finalize_request(r, u, NGX_DECLINED);
|
||||||
|
|
||||||
part = &r->upstream->headers_in.headers.part;
|
part = &u->headers_in.headers.part;
|
||||||
h = part->elts;
|
h = part->elts;
|
||||||
|
|
||||||
for (i = 0; /* void */; i++) {
|
for (i = 0; /* void */; i++) {
|
||||||
@ -1278,7 +1277,7 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uri = &r->upstream->headers_in.x_accel_redirect->value;
|
uri = &u->headers_in.x_accel_redirect->value;
|
||||||
args.len = 0;
|
args.len = 0;
|
||||||
args.data = NULL;
|
args.data = NULL;
|
||||||
flags = 0;
|
flags = 0;
|
||||||
@ -1300,7 +1299,7 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
part = &r->upstream->headers_in.headers.part;
|
part = &u->headers_in.headers.part;
|
||||||
h = part->elts;
|
h = part->elts;
|
||||||
|
|
||||||
for (i = 0; /* void */; i++) {
|
for (i = 0; /* void */; i++) {
|
||||||
@ -2164,9 +2163,9 @@ ngx_http_upstream_store(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (r->upstream->headers_in.last_modified) {
|
if (u->headers_in.last_modified) {
|
||||||
|
|
||||||
last_modified = &r->upstream->headers_in.last_modified->value;
|
last_modified = &u->headers_in.last_modified->value;
|
||||||
|
|
||||||
lm = ngx_http_parse_time(last_modified->data, last_modified->len);
|
lm = ngx_http_parse_time(last_modified->data, last_modified->len);
|
||||||
|
|
||||||
@ -2372,14 +2371,18 @@ ngx_http_upstream_cleanup(void *data)
|
|||||||
{
|
{
|
||||||
ngx_http_request_t *r = data;
|
ngx_http_request_t *r = data;
|
||||||
|
|
||||||
|
ngx_http_upstream_t *u;
|
||||||
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||||
"cleanup http upstream request: \"%V\"", &r->uri);
|
"cleanup http upstream request: \"%V\"", &r->uri);
|
||||||
|
|
||||||
if (r->upstream->resolved && r->upstream->resolved->ctx) {
|
u = r->upstream;
|
||||||
ngx_resolve_name_done(r->upstream->resolved->ctx);
|
|
||||||
|
if (u->resolved && u->resolved->ctx) {
|
||||||
|
ngx_resolve_name_done(u->resolved->ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_http_upstream_finalize_request(r, r->upstream, NGX_DONE);
|
ngx_http_upstream_finalize_request(r, u, NGX_DONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user