From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Georgy Kirichenko Subject: [PATCH] Clear session storage on session stop Date: Tue, 27 Mar 2018 16:29:14 +0300 Message-Id: <6f3087cb542e9a56f53730a2638686ce2e333527.1522156730.git.georgy@tarantool.org> To: tarantool-patches@freelists.org Cc: vdavydov.dev@gmail.com, Georgy Kirichenko List-ID: * session_run_on_disconnect_triggers is called only if there are corresponding triggers so move session_storage_cleanup to session_destroy. * fix session storage cleanup path: use "box.session.aggregate_storage[sid]" instead of "session.aggregate_storage[sid]" (what was wrong) Fixed #3279 --- https://github.com/tarantool/tarantool/tree/gh-3279-clear-session-storage src/box/lua/session.c | 3 +++ src/box/session.cc | 2 +- test/box-tap/session.storage.test.lua | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/box/lua/session.c b/src/box/lua/session.c index ad1c6cc25..51caf199f 100644 --- a/src/box/lua/session.c +++ b/src/box/lua/session.c @@ -376,6 +376,9 @@ session_storage_cleanup(int sid) if (ref == LUA_REFNIL) { lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + if (!lua_istable(L, -1)) + goto exit; + lua_getfield(L, -1, "box"); if (!lua_istable(L, -1)) goto exit; lua_getfield(L, -1, "session"); diff --git a/src/box/session.cc b/src/box/session.cc index 0b0c5ae44..ea6d76bb4 100644 --- a/src/box/session.cc +++ b/src/box/session.cc @@ -166,7 +166,6 @@ session_run_on_disconnect_triggers(struct session *session) { if (session_run_triggers(session, &session_on_disconnect) != 0) diag_log(); - session_storage_cleanup(session->id); } int @@ -184,6 +183,7 @@ session_run_on_auth_triggers(const struct on_auth_trigger_ctx *result) void session_destroy(struct session *session) { + session_storage_cleanup(session->id); struct mh_i64ptr_node_t node = { session->id, NULL }; mh_i64ptr_remove(session_registry, &node, NULL); mempool_free(&session_pool, session); diff --git a/test/box-tap/session.storage.test.lua b/test/box-tap/session.storage.test.lua index 51065954d..40ca9c230 100755 --- a/test/box-tap/session.storage.test.lua +++ b/test/box-tap/session.storage.test.lua @@ -54,7 +54,7 @@ tres2 = conn3:eval("t2 = {} for k, v in pairs(all) do table.insert(t2, v.abc) en table.sort(tres1) table.sort(tres2) test:is(tres1[1], "cde", "check after closing") -test:is(tres2[1], "cde", "check after closing") +test:is(#tres2, 0, "check after closing") conn3:close() inspector:cmd('stop server session_storage with cleanup=1') os.exit(0) -- 2.16.3