forked from erlang/signerl
Fxi the way that TCO starts transaction_sup and tsm_fsm in local-out-begin
This commit is contained in:
parent
bedd015b07
commit
dbb39e1776
|
@ -1,10 +1,11 @@
|
||||||
%%% $Id: tcap_tco_server.erl,v 1.7 2005/08/04 09:33:17 vances Exp $
|
%%% $Id: tcap_tco_server.erl,v 1.7 2005/08/04 09:33:17 vances Exp $
|
||||||
%%%---------------------------------------------------------------------
|
%%%---------------------------------------------------------------------
|
||||||
%%% @copyright 2004-2005 Motivity Telecom
|
%%% @copyright 2004-2005 Motivity Telecom, 2010-2011 Harald Welte
|
||||||
%%% @author Vance Shipley <vances@motivity.ca> [http://www.motivity.ca]
|
%%% @author Vance Shipley <vances@motivity.ca>, Harald Welte <laforge@gnumonks.org>
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%
|
%%%
|
||||||
%%% Copyright (c) 2004-2005, Motivity Telecom
|
%%% Copyright (c) 2004-2005, Motivity Telecom
|
||||||
|
%%% Copyright (c) 2010-2011, Harald Welte
|
||||||
%%%
|
%%%
|
||||||
%%% All rights reserved.
|
%%% All rights reserved.
|
||||||
%%%
|
%%%
|
||||||
|
@ -511,7 +512,7 @@ handle_cast({'TR', 'BEGIN', request, BeginParams}, State)
|
||||||
when is_record(BeginParams, 'TR-BEGIN') ->
|
when is_record(BeginParams, 'TR-BEGIN') ->
|
||||||
% Create a Transaction State Machine (TSM)
|
% Create a Transaction State Machine (TSM)
|
||||||
OTID = BeginParams#'TR-BEGIN'.transactionID,
|
OTID = BeginParams#'TR-BEGIN'.transactionID,
|
||||||
ChildName = list_to_atom("tsm_" ++ integer_to_list(OTID)),
|
ChildName = list_to_atom("tcap_trans_sup_" ++ integer_to_list(OTID)),
|
||||||
%%%% FIXME {ok, {M, F, A, Mods}} = application:get_env(start_tsm),
|
%%%% FIXME {ok, {M, F, A, Mods}} = application:get_env(start_tsm),
|
||||||
StartFunc = get_start(out_transaction, OTID, State),
|
StartFunc = get_start(out_transaction, OTID, State),
|
||||||
ChildSpec = {ChildName, StartFunc, temporary, 1000, worker, [tcap_tsm_fsm]},
|
ChildSpec = {ChildName, StartFunc, temporary, 1000, worker, [tcap_tsm_fsm]},
|
||||||
|
@ -648,18 +649,19 @@ get_start(in_transaction, TransactionID, State) ->
|
||||||
SendFun = fun(P) -> Module:send_primitive(P, State#state.ext_state) end,
|
SendFun = fun(P) -> Module:send_primitive(P, State#state.ext_state) end,
|
||||||
StartDHA = get_start(dialogue, TransactionID, State),
|
StartDHA = get_start(dialogue, TransactionID, State),
|
||||||
StartArgs = [TransactionID, SendFun, StartDHA],
|
StartArgs = [TransactionID, SendFun, StartDHA],
|
||||||
{gen_fsm, start_link, [tcap_dha_fsm, StartArgs, []]}
|
{gen_fsm, start_link, [tcap_tsm_fsm, StartArgs, []]}
|
||||||
end;
|
end;
|
||||||
get_start(out_transaction, TransactionID, State) ->
|
get_start(out_transaction, TransactionID, State) when is_record(State, state) ->
|
||||||
Module = State#state.module,
|
#state{module = Module, supervisor = Sup} = State,
|
||||||
case erlang:function_exported(Module, start_transaction, 1) of
|
case erlang:function_exported(Module, start_transaction, 1) of
|
||||||
true ->
|
true ->
|
||||||
Module:start_transaction(TransactionID, State#state.ext_state);
|
Module:start_transaction(TransactionID, State#state.ext_state);
|
||||||
false ->
|
false ->
|
||||||
SendFun = fun(P) -> Module:send_primitive(P, State#state.ext_state) end,
|
SendFun = fun(P) -> Module:send_primitive(P, State#state.ext_state) end,
|
||||||
StartDHA = get_start(dialogue, TransactionID, State),
|
StartDHA = get_start(dialogue, TransactionID, State),
|
||||||
StartArgs = [TransactionID, SendFun, StartDHA],
|
% FIXME: use StartDHA and pass it into transaction_sup->tsm_fsm
|
||||||
{gen_fsm, start_link, [tcap_dha_fsm, StartArgs, []]}
|
StartArgs = [SendFun, fixme_no_usap, TransactionID, self()],
|
||||||
|
{supervisor, start_link, [tcap_transaction_sup, StartArgs]}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
|
|
|
@ -46,8 +46,8 @@
|
||||||
%%%
|
%%%
|
||||||
|
|
||||||
-module(tcap_tsm_fsm).
|
-module(tcap_tsm_fsm).
|
||||||
-copyright('Copyright (c) 2004-2005 Motivity Telecom Inc.').
|
-copyright('Copyright (c) 2004-2005 Motivity Telecom Inc., 2010-2011 Harald Welte').
|
||||||
-author('vances@motivity.ca').
|
-author('vances@motivity.ca, laforge@gnumonks.org').
|
||||||
-vsn('$Revision: 1.3 $').
|
-vsn('$Revision: 1.3 $').
|
||||||
|
|
||||||
-behaviour(gen_fsm).
|
-behaviour(gen_fsm).
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
-include("TCAPMessages.hrl").
|
-include("TCAPMessages.hrl").
|
||||||
|
|
||||||
%% the transaction_fsm state data
|
%% the transaction_fsm state data
|
||||||
-record(state, {nsap, usap, tco, supervisor, supref, localTID, remoteTID,
|
-record(state, {nsap, usap, tco, dha_sup, supref, localTID, remoteTID,
|
||||||
local_address, remote_address, dha}).
|
local_address, remote_address, dha}).
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
|
@ -75,11 +75,11 @@
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
|
|
||||||
%% initialize the server
|
%% initialize the server
|
||||||
init({NsapFun, USAP, TID, Supervisor, SupRef, TCO}) ->
|
init([NsapFun, USAP, TID, SupRef, TCO]) ->
|
||||||
%% store our process identifier in the global transaction ID table
|
%% store our process identifier in the global transaction ID table
|
||||||
ets:insert(tcap_transaction, {TID, self()}),
|
ets:insert(tcap_transaction, {TID, self()}),
|
||||||
process_flag(trap_exit, true),
|
process_flag(trap_exit, true),
|
||||||
{ok, idle, #state{nsap = NsapFun, usap = USAP, localTID = TID, supervisor = Supervisor,
|
{ok, idle, #state{nsap = NsapFun, usap = USAP, localTID = TID,
|
||||||
supref = SupRef, tco = TCO}}.
|
supref = SupRef, tco = TCO}}.
|
||||||
|
|
||||||
%%%
|
%%%
|
||||||
|
@ -99,7 +99,7 @@ idle({'BEGIN', received, SccpParms}, State)
|
||||||
StartFunc = {supervisor, start_link,
|
StartFunc = {supervisor, start_link,
|
||||||
[tcap_dialogue_sup, [{State#state.usap, State#state.localTID, self()}]]},
|
[tcap_dialogue_sup, [{State#state.usap, State#state.localTID, self()}]]},
|
||||||
ChildSpec = {SupId, StartFunc, permanent, infinity, supervisor, [dialogue_sup]},
|
ChildSpec = {SupId, StartFunc, permanent, infinity, supervisor, [dialogue_sup]},
|
||||||
{ok, DHA} = supervisor:start_child(State#state.supervisor, ChildSpec),
|
{ok, DHA} = supervisor:start_child(State#state.supref, ChildSpec),
|
||||||
QOS = {SccpParms#'N-UNITDATA'.sequenceControl, SccpParms#'N-UNITDATA'.returnOption},
|
QOS = {SccpParms#'N-UNITDATA'.sequenceControl, SccpParms#'N-UNITDATA'.returnOption},
|
||||||
UserData = #'TR-user-data'{dialoguePortion = Begin#'Begin'.dialoguePortion,
|
UserData = #'TR-user-data'{dialoguePortion = Begin#'Begin'.dialoguePortion,
|
||||||
componentPortion = Begin#'Begin'.components},
|
componentPortion = Begin#'Begin'.components},
|
||||||
|
@ -421,7 +421,7 @@ handle_info(Info, StateName, State) ->
|
||||||
terminate(_Reason, _StateName, State) ->
|
terminate(_Reason, _StateName, State) ->
|
||||||
ets:delete(tcap_transaction, State#state.localTID),
|
ets:delete(tcap_transaction, State#state.localTID),
|
||||||
%% signal TCO that we are stopping
|
%% signal TCO that we are stopping
|
||||||
gen_server:cast(State#state.supervisor, {'tsm-stopped', State#state.supref}).
|
gen_server:cast(State#state.tco, {'tsm-stopped', State#state.supref}).
|
||||||
|
|
||||||
%% handle updating state data due to a code replacement
|
%% handle updating state data due to a code replacement
|
||||||
code_change(_OldVsn, StateName, State, _Extra) ->
|
code_change(_OldVsn, StateName, State, _Extra) ->
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
%%% $Id: tcap_transaction_sup.erl,v 1.2 2005/08/04 09:33:17 vances Exp $
|
%%% $Id: tcap_transaction_sup.erl,v 1.2 2005/08/04 09:33:17 vances Exp $
|
||||||
%%%---------------------------------------------------------------------
|
%%%---------------------------------------------------------------------
|
||||||
%%% @copyright 2004-2005 Motivity Telecom
|
%%% @copyright 2004-2005 Motivity Telecom, 2010-2011 Harald Welte
|
||||||
%%% @author Vance Shipley <vances@motivity.ca> [http://www.motivity.ca]
|
%%% @author Vance Shipley <vances@motivity.ca>, Harald Welte <laforge@gnumonks.org>
|
||||||
%%% @end
|
%%% @end
|
||||||
%%%
|
%%%
|
||||||
%%% Copyright (c) 2004-2005, Motivity Telecom
|
%%% Copyright (c) 2004-2005, Motivity Telecom
|
||||||
|
%%% Copyright (c) 2010-2011, Harald Welte
|
||||||
%%%
|
%%%
|
||||||
%%% All rights reserved.
|
%%% All rights reserved.
|
||||||
%%%
|
%%%
|
||||||
|
@ -37,8 +38,8 @@
|
||||||
%%%---------------------------------------------------------------------
|
%%%---------------------------------------------------------------------
|
||||||
|
|
||||||
-module(tcap_transaction_sup).
|
-module(tcap_transaction_sup).
|
||||||
-copyright('Copyright (c) 2003-2005 Motivity Telecom Inc.').
|
-copyright('Copyright (c) 2003-2005 Motivity Telecom Inc., 2010-2011 Harald Welte').
|
||||||
-author('vances@motivity.ca').
|
-author('vances@motivity.ca, laforge@gnumonks.org').
|
||||||
-vsn('$Revision: 1.2 $').
|
-vsn('$Revision: 1.2 $').
|
||||||
|
|
||||||
-behaviour(supervisor).
|
-behaviour(supervisor).
|
||||||
|
@ -46,9 +47,9 @@
|
||||||
%% call backs needed for supervisor behaviour
|
%% call backs needed for supervisor behaviour
|
||||||
-export([init/1]).
|
-export([init/1]).
|
||||||
|
|
||||||
init({NSAP, USAP, TID, SupRef}) ->
|
init([NSAP, USAP, TID, TCO]) ->
|
||||||
Name = list_to_atom("tcap_tsm_" ++ integer_to_list(TID)),
|
Name = list_to_atom("tcap_tsm_" ++ integer_to_list(TID)),
|
||||||
StartArgs = [{local, Name}, tcap_tsm_fsm, [NSAP, USAP, TID, self(), SupRef], []],
|
StartArgs = [{local, Name}, tcap_tsm_fsm, [NSAP, USAP, TID, self(), TCO], []],
|
||||||
StartFunc = {gen_fsm, start_link, StartArgs},
|
StartFunc = {gen_fsm, start_link, StartArgs},
|
||||||
ChildSpec = {Name, StartFunc, permanent, 1000, worker, [tcap_tsm_fsm]},
|
ChildSpec = {Name, StartFunc, permanent, 1000, worker, [tcap_tsm_fsm]},
|
||||||
{ok,{{one_for_all, 0, 1}, [ChildSpec]}}.
|
{ok,{{one_for_all, 0, 1}, [ChildSpec]}}.
|
||||||
|
|
Loading…
Reference in New Issue