aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatarLibravatar daurnimator <quae@daurnimator.com> 2018-07-20 13:44:09 +1000
committerLibravatarLibravatar daurnimator <quae@daurnimator.com> 2018-07-20 13:44:17 +1000
commit162c872aecab9068e752805d36aae63ec4ae24ce (patch)
tree5ac7290688e0e810cb930cebf3d292388cdde8e9 /src
parent056a240fdced921cda162156fac122cb9f14d0a4 (diff)
downloadluaossl-162c872aecab9068e752805d36aae63ec4ae24ce.tar.gz
luaossl-162c872aecab9068e752805d36aae63ec4ae24ce.tar.bz2
luaossl-162c872aecab9068e752805d36aae63ec4ae24ce.zip
src/openssl.c: Avoid reinitializing cache
Diffstat (limited to 'src')
-rw-r--r--src/openssl.c21
1 files changed, 12 insertions, 9 deletions
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() */