From db2baa8f840c67b4f4d10cc1054a8cda62f2cdab Mon Sep 17 00:00:00 2001 From: Christophe Romain Date: Fri, 24 Sep 2010 16:11:39 +0200 Subject: [PATCH] pubsub clean now cluster aware --- src/mod_pubsub/pubsub_clean.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mod_pubsub/pubsub_clean.erl b/src/mod_pubsub/pubsub_clean.erl index 579ccc0f1..814cee0fb 100644 --- a/src/mod_pubsub/pubsub_clean.erl +++ b/src/mod_pubsub/pubsub_clean.erl @@ -2,7 +2,7 @@ -define(TIMEOUT, 1000*600). % 1 minute --export([start/0, loop/0, offline/1]). +-export([start/0, loop/0, purge/0, offline/1]). start() -> Pid = spawn(?MODULE, loop, []), @@ -17,7 +17,8 @@ loop() -> loop(). purge() -> - {Sessions, Subscriptions} = {mnesia:table_info(session,size),mnesia:table_info(pubsub_state,size)}, + Sessions = lists:sum([mnesia:table_info(session,size)|[rpc:call(N,mnesia,table_info,[session,size]) || N <- nodes()]]), + Subscriptions = mnesia:table_info(pubsub_state,size), if Subscriptions > Sessions + 500 -> lists:foreach(fun(K) -> [N]=mnesia:dirty_read({pubsub_node, K}), @@ -34,3 +35,4 @@ offline(Jids) -> lists:filter(fun({U,S,""}) -> ejabberd_sm:get_user_resources(U,S) == []; ({U,S,R}) -> not lists:member(R,ejabberd_sm:get_user_resources(U,S)) end, Jids). +%%ejabberd_cluster:get_node({LUser, LServer})