mirror of
https://github.com/nginx/nginx.git
synced 2024-12-12 18:29:00 +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 {
|
||||
|
||||
host = &r->upstream->resolved->host;
|
||||
host = &u->resolved->host;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
ngx_memzero(&r->upstream->headers_in,
|
||||
sizeof(ngx_http_upstream_headers_in_t));
|
||||
ngx_memzero(&u->headers_in, 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))
|
||||
!= NGX_OK)
|
||||
{
|
||||
@ -1078,7 +1077,7 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
|
||||
|
||||
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))
|
||||
!= 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);
|
||||
|
||||
if (r->upstream->headers_in.x_accel_redirect) {
|
||||
if (u->headers_in.x_accel_redirect) {
|
||||
|
||||
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;
|
||||
|
||||
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.data = NULL;
|
||||
flags = 0;
|
||||
@ -1300,7 +1299,7 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
|
||||
return;
|
||||
}
|
||||
|
||||
part = &r->upstream->headers_in.headers.part;
|
||||
part = &u->headers_in.headers.part;
|
||||
h = part->elts;
|
||||
|
||||
for (i = 0; /* void */; i++) {
|
||||
@ -2164,9 +2163,9 @@ ngx_http_upstream_store(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
||||
|
||||
#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);
|
||||
|
||||
@ -2372,14 +2371,18 @@ ngx_http_upstream_cleanup(void *data)
|
||||
{
|
||||
ngx_http_request_t *r = data;
|
||||
|
||||
ngx_http_upstream_t *u;
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"cleanup http upstream request: \"%V\"", &r->uri);
|
||||
|
||||
if (r->upstream->resolved && r->upstream->resolved->ctx) {
|
||||
ngx_resolve_name_done(r->upstream->resolved->ctx);
|
||||
u = r->upstream;
|
||||
|
||||
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