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

now using p1_fsm behaviour in c2s FSM (EJAB-1173)

SVN Revision: 2936
This commit is contained in:
Evgeniy Khramtsov 2010-01-28 13:00:04 +00:00
parent ce18cfb41b
commit 352afa7902
2 changed files with 3395 additions and 2185 deletions

5367
src/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,9 @@
-author('alexey@process-one.net').
-update_info({update, 0}).
-behaviour(gen_fsm).
-define(GEN_FSM, p1_fsm).
-behaviour(?GEN_FSM).
%% External exports
-export([start/2,
@ -104,8 +106,8 @@
%% Module start with or without supervisor:
-ifdef(NO_TRANSIENT_SUPERVISORS).
-define(SUPERVISOR_START, gen_fsm:start(ejabberd_c2s, [SockData, Opts],
?FSMOPTS)).
-define(SUPERVISOR_START, ?GEN_FSM:start(ejabberd_c2s, [SockData, Opts],
fsm_limit_opts() ++ ?FSMOPTS)).
-else.
-define(SUPERVISOR_START, supervisor:start_child(ejabberd_c2s_sup,
[SockData, Opts])).
@ -140,17 +142,18 @@ start(SockData, Opts) ->
?SUPERVISOR_START.
start_link(SockData, Opts) ->
gen_fsm:start_link(ejabberd_c2s, [SockData, Opts], ?FSMOPTS).
?GEN_FSM:start_link(ejabberd_c2s, [SockData, Opts],
fsm_limit_opts() ++ ?FSMOPTS).
socket_type() ->
xml_stream.
%% Return Username, Resource and presence information
get_presence(FsmRef) ->
gen_fsm:sync_send_all_state_event(FsmRef, {get_presence}, 1000).
?GEN_FSM:sync_send_all_state_event(FsmRef, {get_presence}, 1000).
stop(FsmRef) ->
gen_fsm:send_event(FsmRef, closed).
?GEN_FSM:send_event(FsmRef, closed).
%%%----------------------------------------------------------------------
%%% Callback functions from gen_fsm
@ -221,7 +224,7 @@ init([{SockMod, Socket}, Opts]) ->
%% Return list of all available resources of contacts,
get_subscribed(FsmRef) ->
gen_fsm:sync_send_all_state_event(FsmRef, get_subscribed, 1000).
?GEN_FSM:sync_send_all_state_event(FsmRef, get_subscribed, 1000).
%%----------------------------------------------------------------------
%% Func: StateName/2
@ -903,7 +906,7 @@ session_established({xmlstreamelement, El}, StateData) ->
session_established(timeout, StateData) ->
%% TODO: Options must be stored in state:
Options = [],
proc_lib:hibernate(gen_fsm, enter_loop,
proc_lib:hibernate(?GEN_FSM, enter_loop,
[?MODULE, Options, session_established, StateData]),
fsm_next_state(session_established, StateData);
@ -2153,6 +2156,14 @@ check_from(El, FromJID) ->
end
end.
fsm_limit_opts() ->
case ejabberd_config:get_local_option(max_fsm_queue) of
N when is_integer(N) ->
[{max_queue, N}];
_ ->
[]
end.
%%%----------------------------------------------------------------------
%%% JID Set memory footprint reduction code
%%%----------------------------------------------------------------------