25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-24 17:29:28 +01:00

max_s2s_connexions_number local parameter added.

SVN Revision: 937
This commit is contained in:
Mickaël Rémond 2007-09-14 14:18:51 +00:00
parent f6bf5973ef
commit 78e6eb58d4

View File

@ -32,6 +32,8 @@
-include("jlib.hrl").
-include("ejabberd_ctl.hrl").
-define(DEFAULT_MAX_S2S_CONNEXIONS_NUMBER, 3).
-record(s2s, {fromto, pid, key}).
-record(state, {}).
@ -89,7 +91,7 @@ has_key(FromTo, Key) ->
try_register(FromTo) ->
Key = randoms:get_string(),
Max_S2S_Connexions_Number = 3,
Max_S2S_Connexions_Number = max_s2s_connexions_number(element(1, FromTo)),
F = fun() ->
case mnesia:read({s2s, FromTo}) of
L when length(L) < Max_S2S_Connexions_Number ->
@ -239,7 +241,7 @@ find_connection(From, To) ->
#jid{lserver = MyServer} = From,
#jid{lserver = Server} = To,
FromTo = {MyServer, Server},
Max_S2S_Connexions_Number = 3,
Max_S2S_Connexions_Number = max_s2s_connexions_number(MyServer),
?ERROR_MSG("XXX Finding connection for ~p~n", [FromTo]),
case catch mnesia:dirty_read(s2s, FromTo) of
{'EXIT', Reason} ->
@ -294,6 +296,14 @@ new_connection(MyServer, Server, From, FromTo, Max_S2S_Connexions_Number) ->
end,
TRes.
max_s2s_connexions_number(Host) ->
case ejabberd_config:get_local_option({max_s2s_connexions_number, Host}) of
N when is_integer(N) ->
N;
_ ->
?DEFAULT_MAX_S2S_CONNEXIONS_NUMBER
end.
%%--------------------------------------------------------------------
%% Function: is_service(From, To) -> true | false