Mercurial > hg > nginx-vendor-current
comparison src/http/ngx_http_upstream.c @ 298:30862655219e NGINX_0_5_19
nginx 0.5.19
*) Change: now the $request_time variable has millisecond precision.
*) Change: the method $r->rflush of ngx_http_perl_module was renamed to
the $r->flush.
*) Feature: the $upstream_addr variable.
*) Feature: the "proxy_headers_hash_max_size" and
"proxy_headers_hash_bucket_size" directives.
Thanks to Volodymyr Kostyrko.
*) Bugfix: the files more than 2G could not be transferred using
sendfile and limit_rate on 64-bit platforms.
*) Bugfix: the files more than 2G could not be transferred using
sendfile on 64-bit Linux.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 24 Apr 2007 00:00:00 +0400 |
parents | 2ceaee987f37 |
children | 95d92ec39071 |
comparison
equal
deleted
inserted
replaced
297:df0fd0d43ed8 | 298:30862655219e |
---|---|
70 static ngx_int_t ngx_http_upstream_copy_content_encoding(ngx_http_request_t *r, | 70 static ngx_int_t ngx_http_upstream_copy_content_encoding(ngx_http_request_t *r, |
71 ngx_table_elt_t *h, ngx_uint_t offset); | 71 ngx_table_elt_t *h, ngx_uint_t offset); |
72 #endif | 72 #endif |
73 | 73 |
74 static ngx_int_t ngx_http_upstream_add_variables(ngx_conf_t *cf); | 74 static ngx_int_t ngx_http_upstream_add_variables(ngx_conf_t *cf); |
75 static ngx_int_t ngx_http_upstream_addr_variable(ngx_http_request_t *r, | |
76 ngx_http_variable_value_t *v, uintptr_t data); | |
75 static ngx_int_t ngx_http_upstream_status_variable(ngx_http_request_t *r, | 77 static ngx_int_t ngx_http_upstream_status_variable(ngx_http_request_t *r, |
76 ngx_http_variable_value_t *v, uintptr_t data); | 78 ngx_http_variable_value_t *v, uintptr_t data); |
77 static ngx_int_t ngx_http_upstream_response_time_variable(ngx_http_request_t *r, | 79 static ngx_int_t ngx_http_upstream_response_time_variable(ngx_http_request_t *r, |
78 ngx_http_variable_value_t *v, uintptr_t data); | 80 ngx_http_variable_value_t *v, uintptr_t data); |
79 | 81 |
255 }; | 257 }; |
256 | 258 |
257 | 259 |
258 static ngx_http_variable_t ngx_http_upstream_vars[] = { | 260 static ngx_http_variable_t ngx_http_upstream_vars[] = { |
259 | 261 |
262 { ngx_string("upstream_addr"), NULL, | |
263 ngx_http_upstream_addr_variable, 0, NGX_HTTP_VAR_NOHASH, 0 }, | |
264 | |
260 { ngx_string("upstream_status"), NULL, | 265 { ngx_string("upstream_status"), NULL, |
261 ngx_http_upstream_status_variable, 0, NGX_HTTP_VAR_NOHASH, 0 }, | 266 ngx_http_upstream_status_variable, 0, NGX_HTTP_VAR_NOHASH, 0 }, |
262 | 267 |
263 { ngx_string("upstream_response_time"), NULL, | 268 { ngx_string("upstream_response_time"), NULL, |
264 ngx_http_upstream_response_time_variable, 0, NGX_HTTP_VAR_NOHASH, 0 }, | 269 ngx_http_upstream_response_time_variable, 0, NGX_HTTP_VAR_NOHASH, 0 }, |
2507 return NGX_OK; | 2512 return NGX_OK; |
2508 } | 2513 } |
2509 | 2514 |
2510 | 2515 |
2511 static ngx_int_t | 2516 static ngx_int_t |
2517 ngx_http_upstream_addr_variable(ngx_http_request_t *r, | |
2518 ngx_http_variable_value_t *v, uintptr_t data) | |
2519 { | |
2520 u_char *p; | |
2521 size_t len; | |
2522 ngx_uint_t i; | |
2523 ngx_http_upstream_state_t *state; | |
2524 | |
2525 v->valid = 1; | |
2526 v->no_cachable = 0; | |
2527 v->not_found = 0; | |
2528 | |
2529 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) { | |
2530 v->not_found = 1; | |
2531 return NGX_OK; | |
2532 } | |
2533 | |
2534 len = 0; | |
2535 state = r->upstream_states->elts; | |
2536 | |
2537 for (i = 0; i < r->upstream_states->nelts; i++) { | |
2538 if (state[i].peer) { | |
2539 len += state[i].peer->len + 2; | |
2540 | |
2541 } else { | |
2542 len += 3; | |
2543 } | |
2544 } | |
2545 | |
2546 p = ngx_palloc(r->pool, len); | |
2547 if (p == NULL) { | |
2548 return NGX_ERROR; | |
2549 } | |
2550 | |
2551 v->data = p; | |
2552 | |
2553 i = 0; | |
2554 | |
2555 for ( ;; ) { | |
2556 if (state[i].peer) { | |
2557 p = ngx_cpymem(p, state[i].peer->data, state[i].peer->len); | |
2558 } | |
2559 | |
2560 if (++i == r->upstream_states->nelts) { | |
2561 break; | |
2562 } | |
2563 | |
2564 if (state[i].peer) { | |
2565 *p++ = ','; | |
2566 *p++ = ' '; | |
2567 | |
2568 } else { | |
2569 *p++ = ' '; | |
2570 *p++ = ':'; | |
2571 *p++ = ' '; | |
2572 | |
2573 if (++i == r->upstream_states->nelts) { | |
2574 break; | |
2575 } | |
2576 | |
2577 continue; | |
2578 } | |
2579 } | |
2580 | |
2581 v->len = p - v->data; | |
2582 | |
2583 return NGX_OK; | |
2584 } | |
2585 | |
2586 | |
2587 static ngx_int_t | |
2512 ngx_http_upstream_status_variable(ngx_http_request_t *r, | 2588 ngx_http_upstream_status_variable(ngx_http_request_t *r, |
2513 ngx_http_variable_value_t *v, uintptr_t data) | 2589 ngx_http_variable_value_t *v, uintptr_t data) |
2514 { | 2590 { |
2515 u_char *p; | 2591 u_char *p; |
2516 size_t len; | 2592 size_t len; |