Mercurial > hg > nginx-vendor-current
comparison src/http/modules/ngx_http_upstream_ip_hash_module.c @ 676:bfa81a0490a2 NGINX_1_3_1
nginx 1.3.1
*) Security: now nginx/Windows ignores trailing dot in URI path
component, and does not allow URIs with ":$" in it.
Thanks to Vladimir Kochetkov, Positive Research Center.
*) Feature: the "proxy_pass", "fastcgi_pass", "scgi_pass", "uwsgi_pass"
directives, and the "server" directive inside the "upstream" block,
now support IPv6 addresses.
*) Feature: the "resolver" directive now support IPv6 addresses and an
optional port specification.
*) Feature: the "least_conn" directive inside the "upstream" block.
*) Feature: it is now possible to specify a weight for servers while
using the "ip_hash" directive.
*) Bugfix: a segmentation fault might occur in a worker process if the
"image_filter" directive was used; the bug had appeared in 1.3.0.
*) Bugfix: nginx could not be built with ngx_cpp_test_module; the bug
had appeared in 1.1.12.
*) Bugfix: access to variables from SSI and embedded perl module might
not work after reconfiguration.
Thanks to Yichun Zhang.
*) Bugfix: in the ngx_http_xslt_filter_module.
Thanks to Kuramoto Eiji.
*) Bugfix: memory leak if $geoip_org variable was used.
Thanks to Denis F. Latypoff.
*) Bugfix: in the "proxy_cookie_domain" and "proxy_cookie_path"
directives.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 05 Jun 2012 00:00:00 +0400 |
parents | d0f7a625f27c |
children | 981b4c44593b |
comparison
equal
deleted
inserted
replaced
675:7052a9379344 | 676:bfa81a0490a2 |
---|---|
138 ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data) | 138 ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data) |
139 { | 139 { |
140 ngx_http_upstream_ip_hash_peer_data_t *iphp = data; | 140 ngx_http_upstream_ip_hash_peer_data_t *iphp = data; |
141 | 141 |
142 time_t now; | 142 time_t now; |
143 ngx_int_t w; | |
143 uintptr_t m; | 144 uintptr_t m; |
144 ngx_uint_t i, n, p, hash; | 145 ngx_uint_t i, n, p, hash; |
145 ngx_http_upstream_rr_peer_t *peer; | 146 ngx_http_upstream_rr_peer_t *peer; |
146 | 147 |
147 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, | 148 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, |
164 | 165 |
165 for (i = 0; i < 3; i++) { | 166 for (i = 0; i < 3; i++) { |
166 hash = (hash * 113 + iphp->addr[i]) % 6271; | 167 hash = (hash * 113 + iphp->addr[i]) % 6271; |
167 } | 168 } |
168 | 169 |
169 p = hash % iphp->rrp.peers->number; | 170 if (!iphp->rrp.peers->weighted) { |
171 p = hash % iphp->rrp.peers->number; | |
172 | |
173 } else { | |
174 w = hash % iphp->rrp.peers->total_weight; | |
175 | |
176 for (i = 0; i < iphp->rrp.peers->number; i++) { | |
177 w -= iphp->rrp.peers->peer[i].weight; | |
178 if (w < 0) { | |
179 break; | |
180 } | |
181 } | |
182 | |
183 p = i; | |
184 } | |
170 | 185 |
171 n = p / (8 * sizeof(uintptr_t)); | 186 n = p / (8 * sizeof(uintptr_t)); |
172 m = (uintptr_t) 1 << p % (8 * sizeof(uintptr_t)); | 187 m = (uintptr_t) 1 << p % (8 * sizeof(uintptr_t)); |
173 | 188 |
174 if (!(iphp->rrp.tried[n] & m)) { | 189 if (!(iphp->rrp.tried[n] & m)) { |
227 uscf = ngx_http_conf_get_module_srv_conf(cf, ngx_http_upstream_module); | 242 uscf = ngx_http_conf_get_module_srv_conf(cf, ngx_http_upstream_module); |
228 | 243 |
229 uscf->peer.init_upstream = ngx_http_upstream_init_ip_hash; | 244 uscf->peer.init_upstream = ngx_http_upstream_init_ip_hash; |
230 | 245 |
231 uscf->flags = NGX_HTTP_UPSTREAM_CREATE | 246 uscf->flags = NGX_HTTP_UPSTREAM_CREATE |
247 |NGX_HTTP_UPSTREAM_WEIGHT | |
232 |NGX_HTTP_UPSTREAM_MAX_FAILS | 248 |NGX_HTTP_UPSTREAM_MAX_FAILS |
233 |NGX_HTTP_UPSTREAM_FAIL_TIMEOUT | 249 |NGX_HTTP_UPSTREAM_FAIL_TIMEOUT |
234 |NGX_HTTP_UPSTREAM_DOWN; | 250 |NGX_HTTP_UPSTREAM_DOWN; |
235 | 251 |
236 return NGX_CONF_OK; | 252 return NGX_CONF_OK; |