summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2013-01-17 16:46:35 +0000
committerSimon MacMullen <simon@rabbitmq.com>2013-01-17 16:46:35 +0000
commit31ab9068467652182ed6de357f9e480f6e87e7fd (patch)
tree97732e1396192fd6b09a6326dc8f7d19e757a0f4
parentf90640eda347e7dc1756f5dbe747628816614fc8 (diff)
downloadrabbitmq-server-31ab9068467652182ed6de357f9e480f6e87e7fd.tar.gz
Start the chan_sup_sup later, once we have committed to 0-9-1 - one less hack.
-rw-r--r--src/rabbit_connection_sup.erl14
-rw-r--r--src/rabbit_reader.erl27
2 files changed, 19 insertions, 22 deletions
diff --git a/src/rabbit_connection_sup.erl b/src/rabbit_connection_sup.erl
index f4f3c72f..d9a4735c 100644
--- a/src/rabbit_connection_sup.erl
+++ b/src/rabbit_connection_sup.erl
@@ -42,23 +42,11 @@ start_link() ->
SupPid,
{collector, {rabbit_queue_collector, start_link, []},
intrinsic, ?MAX_WAIT, worker, [rabbit_queue_collector]}),
- %% Note that rabbit_amqp1_0_session_sup_sup despite the name can
- %% mimic rabbit_channel_sup_sup when we handle a 0-9-1 connection
- %% and the 1.0 plugin is loaded.
- ChannelSupSupModule = case code:is_loaded(rabbit_amqp1_0_session_sup_sup) of
- false -> rabbit_channel_sup_sup;
- _ -> rabbit_amqp1_0_session_sup_sup
- end,
- {ok, ChannelSupSupPid} =
- supervisor2:start_child(
- SupPid,
- {channel_sup_sup, {ChannelSupSupModule, start_link, []},
- intrinsic, infinity, supervisor, [rabbit_channel_sup_sup]}),
{ok, ReaderPid} =
supervisor2:start_child(
SupPid,
{reader, {rabbit_reader, start_link,
- [ChannelSupSupPid, Collector,
+ [SupPid, Collector,
rabbit_heartbeat:start_heartbeat_fun(SupPid)]},
intrinsic, ?MAX_WAIT, worker, [rabbit_reader]}),
{ok, SupPid, ReaderPid}.
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl
index a1dfeeff..27ea4d4b 100644
--- a/src/rabbit_reader.erl
+++ b/src/rabbit_reader.erl
@@ -37,7 +37,8 @@
-record(v1, {parent, sock, connection, callback, recv_len, pending_recv,
connection_state, queue_collector, heartbeater, stats_timer,
- channel_sup_sup_pid, start_heartbeat_fun, buf, buf_len, throttle}).
+ channel_sup_sup_pid, conn_sup_pid, start_heartbeat_fun,
+ buf, buf_len, throttle}).
-record(connection, {name, host, peer_host, port, peer_port,
protocol, user, timeout_sec, frame_max, vhost,
@@ -105,12 +106,12 @@ start_link(ChannelSupSupPid, Collector, StartHeartbeatFun) ->
shutdown(Pid, Explanation) ->
gen_server:call(Pid, {shutdown, Explanation}, infinity).
-init(Parent, ChannelSupSupPid, Collector, StartHeartbeatFun) ->
+init(Parent, ConnSupPid, Collector, StartHeartbeatFun) ->
Deb = sys:debug_options([]),
receive
{go, Sock, SockTransform} ->
start_connection(
- Parent, ChannelSupSupPid, Collector, StartHeartbeatFun, Deb, Sock,
+ Parent, ConnSupPid, Collector, StartHeartbeatFun, Deb, Sock,
SockTransform)
end.
@@ -199,7 +200,7 @@ name(Sock) ->
socket_ends(Sock) ->
socket_op(Sock, fun (S) -> rabbit_net:socket_ends(S, inbound) end).
-start_connection(Parent, ChannelSupSupPid, Collector, StartHeartbeatFun, Deb,
+start_connection(Parent, ConnSupPid, Collector, StartHeartbeatFun, Deb,
Sock, SockTransform) ->
process_flag(trap_exit, true),
Name = name(Sock),
@@ -230,7 +231,8 @@ start_connection(Parent, ChannelSupSupPid, Collector, StartHeartbeatFun, Deb,
connection_state = pre_init,
queue_collector = Collector,
heartbeater = none,
- channel_sup_sup_pid = ChannelSupSupPid,
+ conn_sup_pid = ConnSupPid,
+ channel_sup_sup_pid = none,
start_heartbeat_fun = StartHeartbeatFun,
buf = [],
buf_len = 0,
@@ -714,7 +716,13 @@ handle_input(Callback, Data, _State) ->
%% are similar enough that clients will be happy with either.
start_connection({ProtocolMajor, ProtocolMinor, _ProtocolRevision},
Protocol,
- State = #v1{sock = Sock, connection = Connection}) ->
+ State = #v1{sock = Sock, connection = Connection,
+ conn_sup_pid = ConnSupPid}) ->
+ {ok, ChannelSupSupPid} =
+ supervisor2:start_child(
+ ConnSupPid,
+ {channel_sup_sup, {rabbit_channel_sup_sup, start_link, []},
+ intrinsic, infinity, supervisor, [rabbit_channel_sup_sup]}),
Start = #'connection.start'{
version_major = ProtocolMajor,
version_minor = ProtocolMinor,
@@ -725,6 +733,7 @@ start_connection({ProtocolMajor, ProtocolMinor, _ProtocolRevision},
switch_callback(State#v1{connection = Connection#connection{
timeout_sec = ?NORMAL_TIMEOUT,
protocol = Protocol},
+ channel_sup_sup_pid = ChannelSupSupPid,
connection_state = starting},
frame_header, 7).
@@ -1007,9 +1016,9 @@ pack_for_1_0(#v1{parent = Parent,
recv_len = RecvLen,
pending_recv = PendingRecv,
queue_collector = QueueCollector,
- channel_sup_sup_pid = ChannelSupSupPid,
+ conn_sup_pid = ConnSupPid,
start_heartbeat_fun = SHF,
buf = Buf,
buf_len = BufLen}) ->
- {Parent, Sock, RecvLen, PendingRecv, QueueCollector,
- ChannelSupSupPid, SHF, Buf, BufLen}.
+ {Parent, Sock, RecvLen, PendingRecv, QueueCollector, ConnSupPid, SHF,
+ Buf, BufLen}.