From 162c872aecab9068e752805d36aae63ec4ae24ce Mon Sep 17 00:00:00 2001 From: daurnimator Date: Fri, 20 Jul 2018 13:44:09 +1000 Subject: src/openssl.c: Avoid reinitializing cache --- src/openssl.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/openssl.c b/src/openssl.c index 4e7dc8b..f1feebf 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -11357,14 +11357,17 @@ static void initall(lua_State *L) { auxL_addclass(L, OCSP_RESPONSE_CLASS, or_methods, or_metatable, 0); auxL_addclass(L, OCSP_BASICRESP_CLASS, ob_methods, ob_metatable, 0); - /* Create cache for pointers */ - lua_newtable(L); - lua_createtable(L, 0, 2); - lua_pushliteral(L, "kv"); - lua_setfield(L, -2, "__mode"); - lua_pushliteral(L, "luaossl cache"); - lua_setfield(L, -2, "__name"); - lua_setmetatable(L, -2); - lua_rawsetp(L, LUA_REGISTRYINDEX, (void *)&initall); + if (LUA_TNIL == lua_rawgetp(L, LUA_REGISTRYINDEX, (void *)&initall)) { + /* Create cache for pointers */ + lua_newtable(L); + lua_createtable(L, 0, 2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); + lua_pushliteral(L, "luaossl cache"); + lua_setfield(L, -2, "__name"); + lua_setmetatable(L, -2); + lua_rawsetp(L, LUA_REGISTRYINDEX, (void *)&initall); + } + lua_pop(L, 1); } /* initall() */ -- cgit v1.2.3-59-g8ed1b