From ea8557296b63e80c0cedf7635bdc600da4750ee4 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Sat, 13 Feb 2016 19:20:07 +0800 Subject: [PATCH] fix issue #450 --- lualib-src/lua-crypt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lualib-src/lua-crypt.c b/lualib-src/lua-crypt.c index 405679a9..5322b2d6 100644 --- a/lualib-src/lua-crypt.c +++ b/lualib-src/lua-crypt.c @@ -885,7 +885,12 @@ int lhmac_sha1(lua_State *L); int luaopen_crypt(lua_State *L) { luaL_checkversion(L); - srandom(time(NULL)); + static int init = 0; + if (!init) { + // Don't need call srandom more than once. + init = 1 ; + srandom(time(NULL)); + } luaL_Reg l[] = { { "hashkey", lhashkey }, { "randomkey", lrandomkey },