summaryrefslogtreecommitdiff
path: root/src/rabbit_channel_sup.erl
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2010-08-03 13:11:27 +0100
committerMatthew Sackman <matthew@rabbitmq.com>2010-08-03 13:11:27 +0100
commit2c470c48f6d20929d29a543a407e06da63a9028e (patch)
treee3ed1bdab9147e5609cfe18353e8ee35ba470310 /src/rabbit_channel_sup.erl
parentbb9b11a2eb4c76877b43296cd602cec43ca3ad99 (diff)
downloadrabbitmq-server-2c470c48f6d20929d29a543a407e06da63a9028e.tar.gz
Avoid the unnecessary callbacks in the various new _sups as much as possible by breaking the declarative child specs but trying hard to keep them declarative as much as possible.
Diffstat (limited to 'src/rabbit_channel_sup.erl')
-rw-r--r--src/rabbit_channel_sup.erl53
1 files changed, 25 insertions, 28 deletions
diff --git a/src/rabbit_channel_sup.erl b/src/rabbit_channel_sup.erl
index 1d02d992..b565f236 100644
--- a/src/rabbit_channel_sup.erl
+++ b/src/rabbit_channel_sup.erl
@@ -33,7 +33,7 @@
-behaviour(supervisor2).
--export([start_link/8, writer/1, framing_channel/1, channel/1]).
+-export([start_link/8]).
-export([init/1]).
@@ -47,7 +47,7 @@
(rabbit_types:protocol(), rabbit_net:socket(),
rabbit_channel:channel_number(), non_neg_integer(), pid(),
rabbit_access_control:username(), rabbit_types:vhost(), pid()) ->
- ignore | rabbit_types:ok_or_error2(pid(), any())).
+ rabbit_types:ok({pid(), pid()})).
-endif.
@@ -55,32 +55,29 @@
start_link(Protocol, Sock, Channel, FrameMax, ReaderPid, Username, VHost,
Collector) ->
- supervisor2:start_link(?MODULE, [Protocol, Sock, Channel, FrameMax,
- ReaderPid, Username, VHost, Collector]).
-
-writer(Pid) ->
- hd(supervisor2:find_child(Pid, writer)).
-
-channel(Pid) ->
- hd(supervisor2:find_child(Pid, channel)).
-
-framing_channel(Pid) ->
- hd(supervisor2:find_child(Pid, framing_channel)).
+ {ok, SupPid} = supervisor2:start_link(?MODULE, []),
+ {ok, WriterPid} =
+ supervisor2:start_child(
+ SupPid,
+ {writer, {rabbit_writer, start_link,
+ [Sock, Channel, FrameMax, Protocol]},
+ permanent, ?MAX_WAIT, worker, [rabbit_writer]}),
+ {ok, ChannelPid} =
+ supervisor2:start_child(
+ SupPid,
+ {channel, {rabbit_channel, start_link,
+ [Channel, ReaderPid, WriterPid, Username, VHost,
+ Collector]},
+ permanent, ?MAX_WAIT, worker, [rabbit_channel]}),
+ {ok, FramingChannelPid} =
+ supervisor2:start_child(
+ SupPid,
+ {framing_channel, {rabbit_framing_channel, start_link,
+ [ChannelPid, Protocol]},
+ permanent, ?MAX_WAIT, worker, [rabbit_framing_channel]}),
+ {ok, {SupPid, FramingChannelPid}}.
%%----------------------------------------------------------------------------
-init([Protocol, Sock, Channel, FrameMax, ReaderPid, Username, VHost,
- Collector]) ->
- Me = self(),
- {ok, {{one_for_all, 0, 1},
- [{framing_channel, {rabbit_framing_channel, start_link,
- [fun () -> channel(Me) end, Protocol]},
- permanent, ?MAX_WAIT, worker, [rabbit_framing_channel]},
- {writer, {rabbit_writer, start_link,
- [Sock, Channel, FrameMax, Protocol]},
- permanent, ?MAX_WAIT, worker, [rabbit_writer]},
- {channel, {rabbit_channel, start_link,
- [Channel, fun () -> ReaderPid end,
- fun () -> writer(Me) end, Username, VHost, Collector]},
- permanent, ?MAX_WAIT, worker, [rabbit_channel]}
- ]}}.
+init([]) ->
+ {ok, {{one_for_all, 0, 1}, []}}.