diff --git a/TCAP/src/ITU/tcap_cco_server.erl b/TCAP/src/ITU/tcap_cco_server.erl index 539f33a..2eabbfc 100644 --- a/TCAP/src/ITU/tcap_cco_server.erl +++ b/TCAP/src/ITU/tcap_cco_server.erl @@ -236,7 +236,7 @@ process_request_components([Head|Tail], State, AsnComps, ISMs) when invokeID = InvId} -> % if INVOKE component % start ISM and store ISM - {ok, ISM} = tcap_ism_fsm:start_link(Usap, DialogueId, + {ok, ISM} = tcap_invocation_sup:start_ism(Usap, DialogueId, InvId, Class, Tout), % signal 'operation-sent' to ISM gen_fsm:sent_event(ISM, 'operation-sent'), diff --git a/TCAP/src/tcap_components_sup.erl b/TCAP/src/tcap_components_sup.erl index ebecb14..75d84ac 100644 --- a/TCAP/src/tcap_components_sup.erl +++ b/TCAP/src/tcap_components_sup.erl @@ -46,10 +46,20 @@ %% call backs needed for supervisor behaviour -export([init/1]). -init([USAP, ID]) -> +gen_cco_child(USAP, ID) -> Name = list_to_atom("tcap_cco_" ++ integer_to_list(ID)), StartArgs = [{local, Name}, tcap_cco_server, [self(), USAP, ID], [{debug, [trace]}]], StartFunc = {gen_server, start_link, StartArgs}, - ChildSpec = {cco, StartFunc, temporary, 4000, worker, [tcap_cco_server]}, - {ok,{{one_for_all, 0, 1}, [ChildSpec]}}. + {cco, StartFunc, permanent, 4000, worker, [tcap_cco_server]}. + +gen_inv_sup_child(ID) -> + StartFunc = {tcap_invocation_sup, start_link, [ID]}, + {invocation_sup, StartFunc, permanent, 4000, supervisor, [tcap_invocation_sup]}. + +init([USAP, ID]) -> + % start the CCO server as well as a (childless) invocation supervisor + InvSup = gen_inv_sup_child(ID), + Cco = gen_cco_child(USAP, ID), + io:format("~p~n", [InvSup]), + {ok,{{one_for_all, 0, 1}, [InvSup, Cco]}}. diff --git a/TCAP/src/tcap_invocation_sup.erl b/TCAP/src/tcap_invocation_sup.erl index cbd145f..ecf7434 100644 --- a/TCAP/src/tcap_invocation_sup.erl +++ b/TCAP/src/tcap_invocation_sup.erl @@ -46,10 +46,20 @@ %% call backs needed for supervisor behaviour -export([init/1]). -init([USAP, DlgId, InvokeID, OpClass, Timeout]) -> +%% API to other modules +-export([start_ism/1, start_link/1]). + +init([]) -> + {ok,{{one_for_all, 0, 1}, []}}. + +start_ism([USAP, DlgId, InvokeID, OpClass, Timeout]) -> + SupRef = list_to_atom("tcap_invocation_sup_" ++ integer_to_list(DlgId)), StartArgs = [USAP, DlgId, InvokeID, OpClass, Timeout], StartFunc = {tcap_ism_fsm, start_link, StartArgs}, ChildSpec = {ism, StartFunc, temporary, 4000, worker, [tcap_ism_sup]}, - {ok,{{one_for_all, 0, 1}, [ChildSpec]}}. + supervisor:start_child(SupRef, ChildSpec). +start_link(ID) -> + Name = list_to_atom("tcap_invocation_sup_" ++ integer_to_list(ID)), + supervisor:start_link({local, Name}, ?MODULE, []).