1 %%%-------------------------------------------------------------------
2 %%% File : etorrent_t_peer_sup.erl
3 %%% Author : Jesper Louis Andersen <>
4 %%% Description : Supervisor for a peer connection.
6 %%% Created : 10 Jul 2008 by Jesper Louis Andersen <>
7 %%%-------------------------------------------------------------------
8 -module(etorrent_t_peer_sup
).
10 -behaviour(supervisor
).
13 -export([start_link
/6, add_sender
/5]).
15 %% Supervisor callbacks
18 -define(SERVER
, ?MODULE
).
20 %%====================================================================
22 %%====================================================================
23 %%--------------------------------------------------------------------
24 %% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
25 %% Description: Starts the supervisor
26 %%--------------------------------------------------------------------
27 start_link(LocalPeerId
, InfoHash
, FilesystemPid
, GroupPid
, Id
, {IP
, Port
}) ->
28 supervisor:start_link(?MODULE
, [LocalPeerId
,
35 add_sender(Pid
, Socket
, FileSystemPid
, Id
, RecvPid
) ->
36 Sender
= {sender
, {etorrent_t_peer_send
, start_link
,
37 [Socket
, FileSystemPid
, Id
, RecvPid
]},
38 permanent
, 15000, worker
, [etorrent_t_peer_send
]},
39 supervisor:start_child(Pid
, Sender
).
41 %%====================================================================
42 %% Supervisor callbacks
43 %%====================================================================
44 %%--------------------------------------------------------------------
45 %% Func: init(Args) -> {ok, {SupFlags, [ChildSpec]}} |
48 %% Description: Whenever a supervisor is started using
49 %% supervisor:start_link/[2,3], this function is called by the new process
50 %% to find out about restart strategy, maximum restart frequency and child
52 %%--------------------------------------------------------------------
53 init([LocalPeerId
, InfoHash
, FilesystemPid
, GroupPid
, Id
, {IP
, Port
}]) ->
54 Reciever
= {reciever
, {etorrent_t_peer_recv
, start_link
,
55 [LocalPeerId
, InfoHash
, FilesystemPid
, GroupPid
, Id
, self(),
57 permanent
, 15000, worker
, [etorrent_t_peer_recv
]},
58 {ok
, {{one_for_all
, 0, 1}, [Reciever
]}}.
60 %%====================================================================
62 %%====================================================================