thibaultcha / lua-resty-jit-uuid

Fast and dependency-free UUID library for LuaJIT/ngx_lua
http://thibaultcha.github.io/lua-resty-jit-uuid/
MIT License
206 stars 40 forks source link

using math.random for seeding maybe overwrite! #13

Closed inevity closed 7 years ago

inevity commented 7 years ago

using math.random for seeding in init_by_lua maybe overwrite by a math.random from other module .

thibaultcha commented 7 years ago

Hi,

Yes indeed, that is why libraries should never call math.randomseed on their own, and always let the user decide when and how to seed their application. Which is what this library is doing.

BTW, as this library's README warns, if you are seeding in init_by_lua then your workers are generating identical sequences of random numbers (and thus, identical UUIDs if you use this library). You should refer to this lib's README how to fix that.

I proposed https://github.com/openresty/lua-resty-core/pull/92 to OpenResty to address this issue you described for all OpenResty users, but it was not accepted (I think the issue wasn't given the attention it deserved tbh).