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 $
|
||||
%%%---------------------------------------------------------------------
|
||||
%%% @copyright 2004-2005 Motivity Telecom
|
||||
%%% @author Vance Shipley <vances@motivity.ca> [http://www.motivity.ca]
|
||||
%%% @copyright 2004-2005 Motivity Telecom, 2010-2011 Harald Welte
|
||||
%%% @author Vance Shipley <vances@motivity.ca>, Harald Welte <laforge@gnumonks.org>
|
||||
%%% @end
|
||||
%%%
|
||||
%%% Copyright (c) 2004-2005, Motivity Telecom
|
||||
%%% Copyright (c) 2010-2011, Harald Welte
|
||||
%%%
|
||||
%%% All rights reserved.
|
||||
%%%
|
||||
|
@ -511,7 +512,7 @@ handle_cast({'TR', 'BEGIN', request, BeginParams}, State)
|
|||
when is_record(BeginParams, 'TR-BEGIN') ->
|
||||
% Create a Transaction State Machine (TSM)
|
||||
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),
|
||||
StartFunc = get_start(out_transaction, OTID, State),
|
||||
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,
|
||||
StartDHA = get_start(dialogue, TransactionID, State),
|
||||
StartArgs = [TransactionID, SendFun, StartDHA],
|
||||
{gen_fsm, start_link, [tcap_dha_fsm, StartArgs, []]}
|
||||
{gen_fsm, start_link, [tcap_tsm_fsm, StartArgs, []]}
|
||||
end;
|
||||
get_start(out_transaction, TransactionID, State) ->
|
||||
Module = State#state.module,
|
||||
get_start(out_transaction, TransactionID, State) when is_record(State, state) ->
|
||||
#state{module = Module, supervisor = Sup} = State,
|
||||
case erlang:function_exported(Module, start_transaction, 1) of
|
||||
true ->
|
||||
Module:start_transaction(TransactionID, State#state.ext_state);
|
||||
false ->
|
||||
SendFun = fun(P) -> Module:send_primitive(P, State#state.ext_state) end,
|
||||
StartDHA = get_start(dialogue, TransactionID, State),
|
||||
StartArgs = [TransactionID, SendFun, StartDHA],
|
||||
{gen_fsm, start_link, [tcap_dha_fsm, StartArgs, []]}
|
||||
% FIXME: use StartDHA and pass it into transaction_sup->tsm_fsm
|
||||
StartArgs = [SendFun, fixme_no_usap, TransactionID, self()],
|
||||
{supervisor, start_link, [tcap_transaction_sup, StartArgs]}
|
||||
end.
|
||||
|
||||
%%----------------------------------------------------------------------
|
||||
|
|
|
@ -46,8 +46,8 @@
|
|||
%%%
|
||||
|
||||
-module(tcap_tsm_fsm).
|
||||
-copyright('Copyright (c) 2004-2005 Motivity Telecom Inc.').
|
||||
-author('vances@motivity.ca').
|
||||
-copyright('Copyright (c) 2004-2005 Motivity Telecom Inc., 2010-2011 Harald Welte').
|
||||
-author('vances@motivity.ca, laforge@gnumonks.org').
|
||||
-vsn('$Revision: 1.3 $').
|
||||
|
||||
-behaviour(gen_fsm).
|
||||
|
@ -67,7 +67,7 @@
|
|||
-include("TCAPMessages.hrl").
|
||||
|
||||
%% 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}).
|
||||
|
||||
%%----------------------------------------------------------------------
|
||||
|
@ -75,11 +75,11 @@
|
|||
%%----------------------------------------------------------------------
|
||||
|
||||
%% 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
|
||||
ets:insert(tcap_transaction, {TID, self()}),
|
||||
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}}.
|
||||
|
||||
%%%
|
||||
|
@ -99,7 +99,7 @@ idle({'BEGIN', received, SccpParms}, State)
|
|||
StartFunc = {supervisor, start_link,
|
||||
[tcap_dialogue_sup, [{State#state.usap, State#state.localTID, self()}]]},
|
||||
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},
|
||||
UserData = #'TR-user-data'{dialoguePortion = Begin#'Begin'.dialoguePortion,
|
||||
componentPortion = Begin#'Begin'.components},
|
||||
|
@ -421,7 +421,7 @@ handle_info(Info, StateName, State) ->
|
|||
terminate(_Reason, _StateName, State) ->
|
||||
ets:delete(tcap_transaction, State#state.localTID),
|
||||
%% 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
|
||||
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 $
|
||||
%%%---------------------------------------------------------------------
|
||||
%%% @copyright 2004-2005 Motivity Telecom
|
||||
%%% @author Vance Shipley <vances@motivity.ca> [http://www.motivity.ca]
|
||||
%%% @copyright 2004-2005 Motivity Telecom, 2010-2011 Harald Welte
|
||||
%%% @author Vance Shipley <vances@motivity.ca>, Harald Welte <laforge@gnumonks.org>
|
||||
%%% @end
|
||||
%%%
|
||||
%%% Copyright (c) 2004-2005, Motivity Telecom
|
||||
%%% Copyright (c) 2010-2011, Harald Welte
|
||||
%%%
|
||||
%%% All rights reserved.
|
||||
%%%
|
||||
|
@ -37,8 +38,8 @@
|
|||
%%%---------------------------------------------------------------------
|
||||
|
||||
-module(tcap_transaction_sup).
|
||||
-copyright('Copyright (c) 2003-2005 Motivity Telecom Inc.').
|
||||
-author('vances@motivity.ca').
|
||||
-copyright('Copyright (c) 2003-2005 Motivity Telecom Inc., 2010-2011 Harald Welte').
|
||||
-author('vances@motivity.ca, laforge@gnumonks.org').
|
||||
-vsn('$Revision: 1.2 $').
|
||||
|
||||
-behaviour(supervisor).
|
||||
|
@ -46,9 +47,9 @@
|
|||
%% call backs needed for supervisor behaviour
|
||||
-export([init/1]).
|
||||
|
||||
init({NSAP, USAP, TID, SupRef}) ->
|
||||
init([NSAP, USAP, TID, TCO]) ->
|
||||
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},
|
||||
ChildSpec = {Name, StartFunc, permanent, 1000, worker, [tcap_tsm_fsm]},
|
||||
{ok,{{one_for_all, 0, 1}, [ChildSpec]}}.
|
||||
|
|
Loading…
Reference in New Issue