Skip to content

Commit 4232f91

Browse files
committed
Changed shm:get key nil check order
Changed so the key != nil check is done before flags are are set, this makes it so function with (ok, err) return struct have old functionality.
1 parent a68ec99 commit 4232f91

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/resty/core/shdict.lua

+8-8
Original file line numberDiff line numberDiff line change
@@ -296,17 +296,17 @@ end
296296
local function shdict_get(zone, key, flags)
297297
zone = check_zone(zone)
298298

299+
if key == nil then
300+
return nil, "nil key"
301+
end
302+
299303
if flags ~= nil then
300304
user_flags_neq[0] = 1
301305
user_flags[0] = flags
302306
else
303307
user_flags_neq[0] = 0
304308
end
305309

306-
if key == nil then
307-
return nil, "nil key"
308-
end
309-
310310
if type(key) ~= "string" then
311311
key = tostring(key)
312312
end
@@ -382,17 +382,17 @@ end
382382
local function shdict_get_stale(zone, key, flags)
383383
zone = check_zone(zone)
384384

385+
if key == nil then
386+
return nil, "nil key"
387+
end
388+
385389
if flags ~= nil then
386390
user_flags_neq[0] = 1
387391
user_flags[0] = flags
388392
else
389393
user_flags_neq[0] = 0
390394
end
391395

392-
if key == nil then
393-
return nil, "nil key"
394-
end
395-
396396
if type(key) ~= "string" then
397397
key = tostring(key)
398398
end

0 commit comments

Comments
 (0)