26
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-28 17:38:54 +01:00

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} -> {loglevel, Loglevel} ->
ejabberd_loglevel:set(Loglevel), ejabberd_loglevel:set(Loglevel),
State; State;
{max_fsm_queue, N} ->
add_option(max_fsm_queue, N, State);
{_Opt, _Val} -> {_Opt, _Val} ->
lists:foldl(fun(Host, S) -> process_host_term(Term, Host, S) end, lists:foldl(fun(Host, S) -> process_host_term(Term, Host, S) end,
State, State#state.hosts) State, State#state.hosts)

View File

@ -84,15 +84,12 @@
%% Module start with or without supervisor: %% Module start with or without supervisor:
-ifdef(NO_TRANSIENT_SUPERVISORS). -ifdef(NO_TRANSIENT_SUPERVISORS).
-define(SUPERVISOR_START, p1_fsm:start(ejabberd_s2s_out, [From, Host, Type], -define(SUPERVISOR_START, p1_fsm:start(ejabberd_s2s_out, [From, Host, Type],
?FSMLIMITS ++ ?FSMOPTS)). fsm_limit_opts() ++ ?FSMOPTS)).
-else. -else.
-define(SUPERVISOR_START, supervisor:start_child(ejabberd_s2s_out_sup, -define(SUPERVISOR_START, supervisor:start_child(ejabberd_s2s_out_sup,
[From, Host, Type])). [From, Host, Type])).
-endif. -endif.
%% Only change this value if you now what your are doing:
-define(FSMLIMITS,[]).
%% -define(FSMLIMITS, [{max_queue, 2000}]).
-define(FSMTIMEOUT, 30000). -define(FSMTIMEOUT, 30000).
%% We do not block on send anymore. %% We do not block on send anymore.
@ -132,7 +129,7 @@ start(From, Host, Type) ->
start_link(From, Host, Type) -> start_link(From, Host, Type) ->
p1_fsm:start_link(ejabberd_s2s_out, [From, Host, Type], p1_fsm:start_link(ejabberd_s2s_out, [From, Host, Type],
?FSMLIMITS ++ ?FSMOPTS). fsm_limit_opts() ++ ?FSMOPTS).
start_connection(Pid) -> start_connection(Pid) ->
p1_fsm:send_event(Pid, init). p1_fsm:send_event(Pid, init).
@ -1194,3 +1191,11 @@ terminate_if_waiting_delay(From, To) ->
Pid ! terminate_if_waiting_before_retry Pid ! terminate_if_waiting_before_retry
end, end,
Pids). 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, []). -define(FSMOPTS, []).
-endif. -endif.
%% Only change this value if you now what your are doing:
-define(FSMLIMITS,[]).
%% -define(FSMLIMITS, [{max_queue, 2000}]).
-define(STREAM_HEADER, -define(STREAM_HEADER,
"<?xml version='1.0'?>" "<?xml version='1.0'?>"
"<stream:stream " "<stream:stream "
@ -106,8 +102,8 @@ start(SockData, Opts) ->
supervisor:start_child(ejabberd_service_sup, [SockData, Opts]). supervisor:start_child(ejabberd_service_sup, [SockData, Opts]).
start_link(SockData, Opts) -> start_link(SockData, Opts) ->
?GEN_FSM:start_link( ?GEN_FSM:start_link(ejabberd_service, [SockData, Opts],
ejabberd_service, [SockData, Opts], ?FSMLIMITS ++ ?FSMOPTS). fsm_limit_opts(Opts) ++ ?FSMOPTS).
socket_type() -> socket_type() ->
xml_stream. xml_stream.
@ -390,3 +386,16 @@ send_element(StateData, El) ->
new_id() -> new_id() ->
randoms:get_string(). 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.