From a1481f27aa10551029190dc6af9ce395065e277b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micka=C3=ABl=20R=C3=A9mond?= Date: Wed, 1 Aug 2007 09:36:30 +0000 Subject: [PATCH] * src/mod_private.erl: Reduce memory consumption on user private storage removal (EJAB-299). SVN Revision: 852 --- ChangeLog | 5 +++++ src/mod_private.erl | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0bde3807b..2cd91d4eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-08-01 Mickael Remond + + * src/mod_private.erl: Reduce memory consumption on user private + storage removal (EJAB-299). + 2007-07-31 Mickael Remond * src/xml.erl: Making use of CDATA escaping optional through with diff --git a/src/mod_private.erl b/src/mod_private.erl index 6b8925dda..e7361458f 100644 --- a/src/mod_private.erl +++ b/src/mod_private.erl @@ -107,21 +107,21 @@ get_data(LUser, LServer, [El | Els], Res) -> get_data(LUser, LServer, Els, Res) end. - -% TODO: use mnesia:select remove_user(User, Server) -> LUser = jlib:nodeprep(User), LServer = jlib:nameprep(Server), F = fun() -> + Namespaces = mnesia:select( + private_storage, + [{#private_storage{usns={LUser, LServer, '$1'}, + _ = '_'}, + [], + ['$$']}]), lists:foreach( - fun({U, S, _} = Key) -> - if - (U == LUser) and (S == LServer) -> - mnesia:delete({private_storage, Key}); - true -> - ok - end - end, mnesia:all_keys(private_storage)) + fun([Namespace]) -> + mnesia:delete({private_storage, + {LUser, LServer, Namespace}}) + end, Namespaces) end, mnesia:transaction(F). -- 2.40.0