You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/10/05 15:02:28 UTC

[GitHub] [apisix] membphis commented on a change in pull request #2357: bugfix: set random seed for each worker process at `init_worker` phase, only `init` phase is not enough.

membphis commented on a change in pull request #2357:
URL: https://github.com/apache/apisix/pull/2357#discussion_r499666429



##########
File path: apisix/init.lua
##########
@@ -82,6 +75,14 @@ end
 
 
 function _M.http_init_worker()
+    local seed, err = core.utils.get_seed_from_urandom()
+    if not seed then
+        core.log.warn('failed to get seed from urandom: ', err)
+        seed = ngx_now() * 1000 + ngx.worker.pid()
+    end
+    math.randomseed(seed)
+    core.log.info("random test in [1, 10000]: ", math.random(1, 1000000))

Review comment:
       why do we need to remove this line?
   It is necessary for debugging.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org