From 23029adf102b706b9eb050b424ecdf9ec8e78605 Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Wed, 23 Jun 2021 13:42:16 +0200 Subject: [PATCH] Change cache ets table from set to bag As the tables are created per-host-type, a table can have more than one domain within, and so there's no unique key properly defined, considering that the same namepart can be used in two different domains, and the same domain contains many nameparts. Restore it as a set, and actually fix the key inserted --- src/mongoose_users.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mongoose_users.erl b/src/mongoose_users.erl index be124518a2..cb08d3f8bb 100644 --- a/src/mongoose_users.erl +++ b/src/mongoose_users.erl @@ -86,7 +86,7 @@ remove_user(Acc, LUser, LServer) -> mongoose_hooks:simple_acc(). remove_domain(Acc, HostType, Domain) -> Tab = tbl_name(HostType), - ets:match_delete(Tab, {Domain, '_'}), + ets:match_delete(Tab, {{Domain, '_'}}), Acc. %%==================================================================== @@ -107,7 +107,7 @@ does_cached_user_exist(HostType, LServer, LUser) -> put_user_into_cache(HostType, LServer, LUser) -> Key = key(LUser, LServer), Tab = tbl_name(HostType), - ets:insert(Tab, Key), + ets:insert(Tab, {Key}), ok. -spec delete_user(mongooseim:host_type(), jid:lserver(), jid:luser()) -> ok.