Tarantool development patches archive
 help / color / mirror / Atom feed
From: Georgy Kirichenko <georgy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: vdavydov.dev@gmail.com, Georgy Kirichenko <georgy@tarantool.org>
Subject: [PATCH] Clear session storage on session stop
Date: Tue, 27 Mar 2018 16:29:14 +0300	[thread overview]
Message-ID: <6f3087cb542e9a56f53730a2638686ce2e333527.1522156730.git.georgy@tarantool.org> (raw)

* 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

             reply	other threads:[~2018-03-27 13:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-27 13:29 Georgy Kirichenko [this message]
2018-03-27 15:32 ` Vladimir Davydov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6f3087cb542e9a56f53730a2638686ce2e333527.1522156730.git.georgy@tarantool.org \
    --to=georgy@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [PATCH] Clear session storage on session stop' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox