Skip to content
Snippets Groups Projects
Commit e7eea585 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

gh-26: minor optimization of session destructor

The patch should use struct session, which is non-existent
in 1.5, so at least make session_storage_destroy a bit faster.
parent 3c0825b4
No related merge requests found
......@@ -179,21 +179,21 @@ lbox_session_on_disconnect(struct lua_State *L)
void
session_storage_cleanup(int sid)
{
int top = lua_gettop(root_L);
lua_pushliteral(root_L, "box");
lua_rawget(root_L, LUA_GLOBALSINDEX);
lua_pushliteral(root_L, "session");
lua_rawget(root_L, -2);
static int ref = LUA_REFNIL;
lua_getmetatable(root_L, -1);
int top = lua_gettop(root_L);
lua_pushliteral(root_L, "aggregate_storage");
lua_rawget(root_L, -2);
if (ref == LUA_REFNIL) {
lua_getfield(root_L, LUA_GLOBALSINDEX, "box");
lua_getfield(root_L, -1, "session");
lua_getmetatable(root_L, -1);
lua_getfield(root_L, -1, "aggregate_storage");
ref = luaL_ref(root_L, LUA_REGISTRYINDEX);
}
lua_rawgeti(root_L, LUA_REGISTRYINDEX, ref);
lua_pushnil(root_L);
lua_rawseti(root_L, -2, sid);
lua_settop(root_L, top);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment