25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-26 16:26:24 +01:00

* src/mod_offline.erl: Renamed MAX_OFFLINE_MSGS to MaxOfflineMsgs

SVN Revision: 881
This commit is contained in:
Alexey Shchepin 2007-08-20 18:02:12 +00:00
parent 262cff552b
commit 8cc493a43f
2 changed files with 13 additions and 12 deletions

View File

@ -1,5 +1,7 @@
2007-08-20 Alexey Shchepin <alexey@process-one.net> 2007-08-20 Alexey Shchepin <alexey@process-one.net>
* src/mod_offline.erl: Renamed MAX_OFFLINE_MSGS to MaxOfflineMsgs
* src/odbc/ejabberd_odbc_sup.erl: Add an odbc_pool_size config * src/odbc/ejabberd_odbc_sup.erl: Add an odbc_pool_size config
file option to choose the number of SQL connection in each pool file option to choose the number of SQL connection in each pool
(EJAB-58) (thanks to Jerome Sautret) (EJAB-58) (thanks to Jerome Sautret)

View File

@ -3,7 +3,6 @@
%%% Author : Alexey Shchepin <alexey@process-one.net> %%% Author : Alexey Shchepin <alexey@process-one.net>
%%% Purpose : Store and manage offline messages in Mnesia database. %%% Purpose : Store and manage offline messages in Mnesia database.
%%% Created : 5 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% Created : 5 Jan 2003 by Alexey Shchepin <alexey@process-one.net>
%%% Id : $Id$
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
-module(mod_offline). -module(mod_offline).
@ -43,25 +42,25 @@ start(Host, Opts) ->
?MODULE, remove_user, 50), ?MODULE, remove_user, 50),
ejabberd_hooks:add(anonymous_purge_hook, Host, ejabberd_hooks:add(anonymous_purge_hook, Host,
?MODULE, remove_user, 50), ?MODULE, remove_user, 50),
MAX_OFFLINE_MSGS = gen_mod:get_opt(user_max_messages, Opts, infinity), MaxOfflineMsgs = gen_mod:get_opt(user_max_messages, Opts, infinity),
register(gen_mod:get_module_proc(Host, ?PROCNAME), register(gen_mod:get_module_proc(Host, ?PROCNAME),
spawn(?MODULE, init, [MAX_OFFLINE_MSGS])). spawn(?MODULE, init, [MaxOfflineMsgs])).
%% MAX_OFFLINE_MSGS is either infinity of integer > 0 %% MaxOfflineMsgs is either infinity of integer > 0
init(infinity) -> init(infinity) ->
loop(infinity); loop(infinity);
init(MAX_OFFLINE_MSGS) init(MaxOfflineMsgs)
when integer(MAX_OFFLINE_MSGS), MAX_OFFLINE_MSGS > 0 -> when integer(MaxOfflineMsgs), MaxOfflineMsgs > 0 ->
loop(MAX_OFFLINE_MSGS). loop(MaxOfflineMsgs).
loop(MAX_OFFLINE_MSGS) -> loop(MaxOfflineMsgs) ->
receive receive
#offline_msg{us=US} = Msg -> #offline_msg{us=US} = Msg ->
Msgs = receive_all(US, [Msg]), Msgs = receive_all(US, [Msg]),
Len = length(Msgs), Len = length(Msgs),
F = fun() -> F = fun() ->
%% Only count messages if needed: %% Only count messages if needed:
Count = if MAX_OFFLINE_MSGS =/= infinity -> Count = if MaxOfflineMsgs =/= infinity ->
Len + p1_mnesia:count_records( Len + p1_mnesia:count_records(
offline_msg, offline_msg,
#offline_msg{us=US, _='_'}); #offline_msg{us=US, _='_'});
@ -69,7 +68,7 @@ loop(MAX_OFFLINE_MSGS) ->
0 0
end, end,
if if
Count > MAX_OFFLINE_MSGS -> Count > MaxOfflineMsgs ->
discard_warn_sender(Msgs); discard_warn_sender(Msgs);
true -> true ->
if if
@ -84,9 +83,9 @@ loop(MAX_OFFLINE_MSGS) ->
end end
end, end,
mnesia:transaction(F), mnesia:transaction(F),
loop(MAX_OFFLINE_MSGS); loop(MaxOfflineMsgs);
_ -> _ ->
loop(MAX_OFFLINE_MSGS) loop(MaxOfflineMsgs)
end. end.
receive_all(US, Msgs) -> receive_all(US, Msgs) ->