evanmiller/nginx_upstream_hash — pull request #6 by zls0424 (2013-05-31 10:02:10+00:00)
Title: Bug fix for infinite loop.

Consider the following step:

hash_again = 1 => pc->tries = 2

After ngx_http_upstream_init_hash_peer -> ngx_http_upstream_hash_next_peer, pc->tries becomes 1.
If the first upstream fails, after ngx_http_upstream_free_hash_peer -> ngx_http_upstream_hash_next_peer,
pc->tries becomes (ngx_uint_t) -1.

Maybe a better patch is needed, and this one just fix the problem.

Easy to reproduce: (curl localhost/xxxx)

```nginx
upstream not_exists {
server localhost:9999;
server localhost:9999;
server localhost:9999;
server localhost:9999;
server localhost:9999;
server localhost:9999;
server localhost:9999;
server localhost:9999;

hash $args;
hash_again 1;
}

server {
listen 80;

location / {
proxy_pass http://not_exists;
}
}
```