spacewander commented on a change in pull request #5682: URL: https://github.com/apache/apisix/pull/5682#discussion_r762551643
########## File path: .luacheckrc ########## @@ -2,6 +2,13 @@ std = "ngx_lua" unused_args = false redefined = false max_line_length = 100 + exclude_files = { "apisix/cli/ngx_tpl.lua", } + +files["apisix/patch.lua"] = { Review comment: We can solve in this way, which is consistent: https://github.com/apache/apisix/blob/6e09d56e9c93666b52fccdeb6e1d3fb1178b678c/apisix/patch.lua#L310-L311 ########## File path: apisix/patch.lua ########## @@ -86,6 +92,53 @@ do end +-- Inspired by kong.globalpatches +do -- `_G.math.randomseed` patch + local resty_random = require("resty.random") + local math_randomseed = math.randomseed + local seeded = {} + -- make linter happy + -- luacheck: ignore + _G.math.randomseed = function() + local seed + local worker_pid = ngx.worker.pid() + + -- check seed mark + if seeded[worker_pid] then + log(WARN, debug.traceback("attempt to seed already seeded random number " .. + "generator on process #" .. tostring(worker_pid), 2)) + return + end + + -- get randomseed + local bytes = resty_random.bytes(8) + if bytes then + log(ngx.INFO, "seeding from resty.random.bytes") + + local t = {} + for i = 1, #bytes do Review comment: `for i = 1, min(#bytes, 12) do` should be already OK? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org