diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl index eba01159f..c980da477 100644 --- a/src/ejabberd_config.erl +++ b/src/ejabberd_config.erl @@ -387,6 +387,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) diff --git a/src/ejabberd_s2s_out.erl b/src/ejabberd_s2s_out.erl index 85f6a0618..cb5bcbf91 100644 --- a/src/ejabberd_s2s_out.erl +++ b/src/ejabberd_s2s_out.erl @@ -85,15 +85,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. @@ -121,7 +118,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). @@ -1147,3 +1144,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. diff --git a/src/ejabberd_service.erl b/src/ejabberd_service.erl index 6379de19d..f06d7cc23 100644 --- a/src/ejabberd_service.erl +++ b/src/ejabberd_service.erl @@ -70,11 +70,6 @@ -define(DEFAULT_NS, ?NS_COMPONENT_ACCEPT). -define(PREFIXED_NS, [{?NS_XMPP, ?NS_XMPP_pfx}]). -%% Only change this value if you now what your are doing: --define(FSMLIMITS,[]). -%% -define(FSMLIMITS, [{max_queue, 2000}]). - - %%%---------------------------------------------------------------------- %%% API %%%---------------------------------------------------------------------- @@ -82,8 +77,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 +385,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.