Skip to content

Commit e3fa62c

Browse files
committed
fix(randomseed) do not randomseed from a library
The rnadom number generator contains application level state and hence should NEVER be seeded from a library. Seeding it is an application level responsibility, always.
1 parent ab2872a commit e3fa62c

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

mqtt/client.lua

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ local coroutine_yield = coroutine.yield
3232

3333
local math = require("math")
3434
local math_random = math.random
35-
local math_randomseed = math.randomseed
3635

3736
local luamqtt_VERSION
3837

@@ -55,11 +54,6 @@ local ioloop_get = ioloop.get
5554

5655
-------
5756

58-
-- pseudo-random generator initialized flag
59-
local random_initialized = false
60-
61-
-------
62-
6357
--- MQTT client instance metatable
6458
-- @type client_mt
6559
local client_mt = {}
@@ -158,11 +152,6 @@ function client_mt:__init(args)
158152

159153
if not a.id then
160154
-- generate random client id
161-
if not random_initialized then
162-
-- initialize pseudo-random generator with current time seed
163-
math_randomseed(os_time())
164-
random_initialized = true
165-
end
166155
a.id = str_format("luamqtt-v%s-%07x", str_gsub(luamqtt_VERSION, "[^%d]", "-"), math_random(1, 0xFFFFFFF))
167156
end
168157

0 commit comments

Comments
 (0)