1%%
2%% %CopyrightBegin%
3%%
4%% Copyright Ericsson AB 2003-2016. All Rights Reserved.
5%%
6%% Licensed under the Apache License, Version 2.0 (the "License");
7%% you may not use this file except in compliance with the License.
8%% You may obtain a copy of the License at
9%%
10%%     http://www.apache.org/licenses/LICENSE-2.0
11%%
12%% Unless required by applicable law or agreed to in writing, software
13%% distributed under the License is distributed on an "AS IS" BASIS,
14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15%% See the License for the specific language governing permissions and
16%% limitations under the License.
17%%
18%% %CopyrightEnd%
19%%
20
21%%
22%%----------------------------------------------------------------------
23%% Purpose: The supervisor for the Megaco/H.248 transaction sender
24%%          processes.
25%%----------------------------------------------------------------------
26
27-module(megaco_trans_sup).
28
29-behaviour(supervisor).
30
31%% public
32-export([start/0, stop/1, init/1]).
33-export([start_trans_sender/5]).
34
35%% -define(d(F,A), io:format("~p~p:" ++ F ++ "~n", [self(),?MODULE|A])).
36-define(d(F,A), ok).
37
38start() ->
39    ?d("start -> entry",[]),
40    SupName = {local,?MODULE},
41    supervisor:start_link(SupName, ?MODULE, []).
42
43stop(_StartArgs) ->
44    ok.
45
46init([]) ->
47    init();
48init(BadArg) ->
49    {error, {badarg, BadArg}}.
50
51init() ->
52    ?d("init -> entry",[]),
53    Flags     = {one_for_one, 500, 100},
54    Workers   = [],
55    ?d("init -> done",[]),
56    {ok, {Flags, Workers}}.
57
58
59%%----------------------------------------------------------------------
60%% Function: start_ack_sender/3
61%% Description: Starts a transient worker (child) process
62%%----------------------------------------------------------------------
63
64start_trans_sender(CH, To, ReqsMaxSz, ReqsMax, AcksMax) ->
65    ?d("start_ack_sender -> entry with"
66	"~n   CH:        ~p"
67	"~n   To:        ~p"
68	"~n   ReqsMaxSz: ~p"
69	"~n   ReqsMax:   ~p"
70	"~n   AxksMax:   ~p", [CH, To, ReqsMaxSz, ReqsMax, AcksMax]),
71    M = megaco_trans_sender,
72    F = start_link,
73    A = [CH, To, ReqsMaxSz, ReqsMax, AcksMax],
74    N = {M,CH},
75    Spec = {N,
76	    {M,F,A},
77	    temporary, timer:seconds(1), worker, [M,gen_server]},
78    case supervisor:start_child(?MODULE, Spec) of
79	{error, already_present} ->
80	    supervisor:restart_child(?MODULE, N);
81	Else ->
82	    Else
83    end.
84
85
86
87
88
89
90