new option added: max_fsm_queue. removed hardcoded FSMLIMITS

SVN Revision: 2645
This commit is contained in:
Evgeniy Khramtsov 2009-10-07 14:24:09 +00:00
parent 72535ee14d
commit 14232df14c
3 changed files with 27 additions and 11 deletions

View File

@ -386,6 +386,8 @@ process_term(Term, State) ->
{loglevel, Loglevel} ->
ejabberd_loglevel:set(Loglevel),
State;
{max_fsm_queue, N} ->
add_option(max_fsm_queue, N, State);
{_Opt, _Val} ->
lists:foldl(fun(Host, S) -> process_host_term(Term, Host, S) end,
State, State#state.hosts)

View File

@ -84,15 +84,12 @@
%% Module start with or without supervisor:
-ifdef(NO_TRANSIENT_SUPERVISORS).
-define(SUPERVISOR_START, p1_fsm:start(ejabberd_s2s_out, [From, Host, Type],
?FSMLIMITS ++ ?FSMOPTS)).
fsm_limit_opts() ++ ?FSMOPTS)).
-else.
-define(SUPERVISOR_START, supervisor:start_child(ejabberd_s2s_out_sup,
[From, Host, Type])).
-endif.
%% Only change this value if you now what your are doing:
-define(FSMLIMITS,[]).
%% -define(FSMLIMITS, [{max_queue, 2000}]).
-define(FSMTIMEOUT, 30000).
%% We do not block on send anymore.
@ -132,7 +129,7 @@ start(From, Host, Type) ->
start_link(From, Host, Type) ->
p1_fsm:start_link(ejabberd_s2s_out, [From, Host, Type],
?FSMLIMITS ++ ?FSMOPTS).
fsm_limit_opts() ++ ?FSMOPTS).
start_connection(Pid) ->
p1_fsm:send_event(Pid, init).
@ -1194,3 +1191,11 @@ terminate_if_waiting_delay(From, To) ->
Pid ! terminate_if_waiting_before_retry
end,
Pids).
fsm_limit_opts() ->
case ejabberd_config:get_local_option(max_fsm_queue) of
N when is_integer(N) ->
[{max_queue, N}];
_ ->
[]
end.

View File

@ -64,10 +64,6 @@
-define(FSMOPTS, []).
-endif.
%% Only change this value if you now what your are doing:
-define(FSMLIMITS,[]).
%% -define(FSMLIMITS, [{max_queue, 2000}]).
-define(STREAM_HEADER,
"<?xml version='1.0'?>"
"<stream:stream "
@ -106,8 +102,8 @@ start(SockData, Opts) ->
supervisor:start_child(ejabberd_service_sup, [SockData, Opts]).
start_link(SockData, Opts) ->
?GEN_FSM:start_link(
ejabberd_service, [SockData, Opts], ?FSMLIMITS ++ ?FSMOPTS).
?GEN_FSM:start_link(ejabberd_service, [SockData, Opts],
fsm_limit_opts(Opts) ++ ?FSMOPTS).
socket_type() ->
xml_stream.
@ -390,3 +386,16 @@ send_element(StateData, El) ->
new_id() ->
randoms:get_string().
fsm_limit_opts(Opts) ->
case lists:keysearch(max_fsm_queue, 1, Opts) of
{value, {_, N}} when is_integer(N) ->
[{max_queue, N}];
_ ->
case ejabberd_config:get_local_option(max_fsm_queue) of
N when is_integer(N) ->
[{max_queue, N}];
_ ->
[]
end
end.