From 2118efcdce52de304796c5d0d7cf12cd50dfdca6 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Mon, 18 May 2020 13:40:38 +0200 Subject: [PATCH] fix(ARM) workaround for LuaJIT/ARM bug fixes #93 --- README.md | 7 ++++++- src/resty/dns/balancer/ring.lua | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3503f081c9a1..133588876e1d 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ Release process: 4. commit and tag the release 5. upload rock to LuaRocks +### 5.0.x (unreleased) + +- Fix: workaround for LuaJIT/ARM bug, see [Issue 93](https://github.com/Kong/lua-resty-dns-client/issues/93). + + ### 5.0.0 (14-May-2020) - BREAKING: `getPeer` now returns the host-header value instead of the hostname @@ -59,7 +64,7 @@ Release process: ip-address as the hostname, but will now return `nil`. See [PR 89](https://github.com/Kong/lua-resty-dns-client/pull/89). - Added: option `useSRVname`, if truthy then `getPeer` will return the name as found - in the SRV record, instead of the hostname as added to the balancer. + in the SRV record, instead of the hostname as added to the balancer. See [PR 89](https://github.com/Kong/lua-resty-dns-client/pull/89). - Added: callback return an extra parameter; the host-header for the address added/removed. - Fix: using the module instance instead of the passed one for dns resolution diff --git a/src/resty/dns/balancer/ring.lua b/src/resty/dns/balancer/ring.lua index aca2954724d2..6d6ba6ccea75 100644 --- a/src/resty/dns/balancer/ring.lua +++ b/src/resty/dns/balancer/ring.lua @@ -103,6 +103,7 @@ function ring_address:addIndices(availableIndicesList, count) return self end + -- Drop an amount of indices and return them to the overall balancer. -- @param availableIndicesList The list to add the dropped indices to -- @param count (optional) The number of indices to drop, defaults to ALL if omitted @@ -133,7 +134,14 @@ function ring_address:dropIndices(availableIndicesList, count) -- table was reduced by at least half, so drop the original to reduce -- memory footprint self.indicesMax = size + --[[ next line disabled due to LuaJIT/ARM issue, see https://github.com/Kong/lua-resty-dns-client/issues/93 self.indices = table.move(self.indices, 1, size, 1, {}) + Below a pure-Lua implementation --]] + local replacement = {} + for i = 1, size do + replacement[i] = self.indices[i] + end + self.indices = replacement end end return availableIndicesList