]> granicus.if.org Git - ejabberd/commitdiff
* src/mod_private.erl: Reduce memory consumption on user private
authorMickaël Rémond <mickael.remond@process-one.net>
Thu, 9 Aug 2007 16:01:32 +0000 (16:01 +0000)
committerMickaël Rémond <mickael.remond@process-one.net>
Thu, 9 Aug 2007 16:01:32 +0000 (16:01 +0000)
storage removal (EJAB-299).

SVN Revision: 867

ChangeLog
src/mod_private.erl

index edeed48b979a12dca6ca28a66b4ac7fcbee407fa..4ccba333133e6d5e8cb82618a5c58e4b6d9359f1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-08-01  Mickael Remond  <mickael.remond@process-one.net>
+
+       * src/mod_private.erl: Reduce memory consumption on user private
+       storage removal (EJAB-299).
+
 2007-06-29  Mickael Remond  <mickael.remond@process-one.net>
                
        * src/ejabberd_config.erl: Normalize hostnames in config file. If mixed
index 6b8925dda77e6413d04b9584a8153c865a60268e..e7361458f7c282a67fc93f0d49b3e70049635578 100644 (file)
@@ -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).