diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2007-04-24 06:21:18 +0000 |
|---|---|---|
| committer | Jonathan Kolb <jon@b0g.us> | 2007-04-24 06:21:18 +0000 |
| commit | 9b4b08199402bb1b2a276b9b36227598140c33af (patch) | |
| tree | 3d277e270cb1e4b7c81a7b24e089cf99db4c5195 /src/http/ngx_http_upstream.c | |
| parent | efb46f1637bbe2cf93311b48bd32e0c702ae2af7 (diff) | |
| download | nginx-9b4b08199402bb1b2a276b9b36227598140c33af.tar.gz | |
Changes with nginx 0.5.19 24 Apr 2007v0.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.
Diffstat (limited to 'src/http/ngx_http_upstream.c')
| -rw-r--r-- | src/http/ngx_http_upstream.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index fe7ae4a53..a88f5c5e4 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -72,6 +72,8 @@ static ngx_int_t ngx_http_upstream_copy_content_encoding(ngx_http_request_t *r, #endif static ngx_int_t ngx_http_upstream_add_variables(ngx_conf_t *cf); +static ngx_int_t ngx_http_upstream_addr_variable(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_upstream_status_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_upstream_response_time_variable(ngx_http_request_t *r, @@ -257,6 +259,9 @@ ngx_module_t ngx_http_upstream_module = { static ngx_http_variable_t ngx_http_upstream_vars[] = { + { ngx_string("upstream_addr"), NULL, + ngx_http_upstream_addr_variable, 0, NGX_HTTP_VAR_NOHASH, 0 }, + { ngx_string("upstream_status"), NULL, ngx_http_upstream_status_variable, 0, NGX_HTTP_VAR_NOHASH, 0 }, @@ -2509,6 +2514,77 @@ ngx_http_upstream_add_variables(ngx_conf_t *cf) static ngx_int_t +ngx_http_upstream_addr_variable(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data) +{ + u_char *p; + size_t len; + ngx_uint_t i; + ngx_http_upstream_state_t *state; + + v->valid = 1; + v->no_cachable = 0; + v->not_found = 0; + + if (r->upstream_states == NULL || r->upstream_states->nelts == 0) { + v->not_found = 1; + return NGX_OK; + } + + len = 0; + state = r->upstream_states->elts; + + for (i = 0; i < r->upstream_states->nelts; i++) { + if (state[i].peer) { + len += state[i].peer->len + 2; + + } else { + len += 3; + } + } + + p = ngx_palloc(r->pool, len); + if (p == NULL) { + return NGX_ERROR; + } + + v->data = p; + + i = 0; + + for ( ;; ) { + if (state[i].peer) { + p = ngx_cpymem(p, state[i].peer->data, state[i].peer->len); + } + + if (++i == r->upstream_states->nelts) { + break; + } + + if (state[i].peer) { + *p++ = ','; + *p++ = ' '; + + } else { + *p++ = ' '; + *p++ = ':'; + *p++ = ' '; + + if (++i == r->upstream_states->nelts) { + break; + } + + continue; + } + } + + v->len = p - v->data; + + return NGX_OK; +} + + +static ngx_int_t ngx_http_upstream_status_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) { |
