Tarantool development patches archive
 help / color / mirror / Atom feed
* [PATCH] Clear session storage on session stop
@ 2018-03-27 13:29 Georgy Kirichenko
  2018-03-27 15:32 ` Vladimir Davydov
  0 siblings, 1 reply; 2+ messages in thread
From: Georgy Kirichenko @ 2018-03-27 13:29 UTC (permalink / raw)
  To: tarantool-patches; +Cc: vdavydov.dev, Georgy Kirichenko

* 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Clear session storage on session stop
  2018-03-27 13:29 [PATCH] Clear session storage on session stop Georgy Kirichenko
@ 2018-03-27 15:32 ` Vladimir Davydov
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Davydov @ 2018-03-27 15:32 UTC (permalink / raw)
  To: Georgy Kirichenko; +Cc: tarantool-patches

Looks good to me.

On Tue, Mar 27, 2018 at 04:29:14PM +0300, Georgy Kirichenko wrote:
> * 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(-)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-27 15:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-27 13:29 [PATCH] Clear session storage on session stop Georgy Kirichenko
2018-03-27 15:32 ` Vladimir Davydov

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