lua-upstream-nginx-module
lua-upstream-nginx-module copied to clipboard
Iterate peers as linked list instead of array
Accessing peers as an array has been deprecated since nginx 1.9.0 (changeset 6100 - http://hg.nginx.org/nginx/rev/c44459611d91) and does not work when using the zone
directive in upstream
block. This commit changes iteration to use peer->next
and iterate as a linked list.
This PR should solve https://github.com/openresty/lua-upstream-nginx-module/issues/31 and https://github.com/openresty/lua-upstream-nginx-module/issues/61
I got this reply when I asked regarding this in nginx-devel mailing list:
The ngx_lua_upstream module is not adapted to work with peers stored in memory as a linked list, thus it cannot be used with upstream zone that copies peers from configuration to shared memory one by one, thus the peers' layout is effectively changed from an array to a linked list. The problem you observe is that lua iterates peers by index as an array.
See this change as a guidance: http://hg.nginx.org/nginx/rev/c44459611d91