summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2013-01-08 14:39:48 +0000
committerSimon MacMullen <simon@rabbitmq.com>2013-01-08 14:39:48 +0000
commitd5d767375b99934047b6f12e99ea63a7d414255c (patch)
tree29842477b4465d9b3146210f63894ceee336e21f
parentafebcd8aaa467f0a4f8ade278d9b4c019bf96275 (diff)
downloadrabbitmq-server-git-d5d767375b99934047b6f12e99ea63a7d414255c.tar.gz
Stub for 1.0 support.
-rw-r--r--src/rabbit_connection_sup.erl9
-rw-r--r--src/rabbit_reader.erl34
2 files changed, 42 insertions, 1 deletions
diff --git a/src/rabbit_connection_sup.erl b/src/rabbit_connection_sup.erl
index 12a532b6fc..f4f3c72feb 100644
--- a/src/rabbit_connection_sup.erl
+++ b/src/rabbit_connection_sup.erl
@@ -42,10 +42,17 @@ 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, {rabbit_channel_sup_sup, start_link, []},
+ {channel_sup_sup, {ChannelSupSupModule, start_link, []},
intrinsic, infinity, supervisor, [rabbit_channel_sup_sup]}),
{ok, ReaderPid} =
supervisor2:start_child(
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl
index 13e8feff08..f140bd237c 100644
--- a/src/rabbit_reader.erl
+++ b/src/rabbit_reader.erl
@@ -689,6 +689,15 @@ handle_input(handshake, <<"AMQP", 1, 1, 8, 0>>, State) ->
handle_input(handshake, <<"AMQP", 1, 1, 9, 1>>, State) ->
start_connection({8, 0, 0}, rabbit_framing_amqp_0_8, State);
+%% ... and finally, the 1.0 spec is crystal clear! Note that the
+%% FIXME TLS uses a different protocol number, and would go here.
+handle_input(handshake, <<"AMQP", 0, 1, 0, 0>>, State) ->
+ become_1_0(amqp, [0, 1, 0, 0], State);
+
+%% 3 stands for "SASL"
+handle_input(handshake, <<"AMQP", 3, 1, 0, 0>>, State) ->
+ become_1_0(sasl, [0, 3, 0, 0], State);
+
handle_input(handshake, <<"AMQP", A, B, C, D>>, #v1{sock = Sock}) ->
refuse_connection(Sock, {bad_version, A, B, C, D});
@@ -981,3 +990,28 @@ cert_info(F, #v1{sock = Sock}) ->
emit_stats(State) ->
rabbit_event:notify(connection_stats, infos(?STATISTICS_KEYS, State)),
rabbit_event:reset_stats_timer(State, #v1.stats_timer).
+
+%% 1.0 stub
+
+become_1_0(Mode, HandshakeBytes, State = #v1{sock = Sock}) ->
+ case code:is_loaded(rabbit_amqp1_0_reader) of
+ false -> refuse_connection(
+ Sock, list_to_tuple([bad_version | HandshakeBytes]));
+ _ -> apply0(rabbit_amqp1_0_reader, become,
+ [Mode, pack_for_1_0(State)])
+ end.
+
+%% Fool xref. Simply using apply(M, F, A) with constants is not enough.
+apply0(M, F, A) -> apply(M, F, A).
+
+pack_for_1_0(#v1{parent = Parent,
+ sock = Sock,
+ recv_len = RecvLen,
+ pending_recv = PendingRecv,
+ queue_collector = QueueCollector,
+ channel_sup_sup_pid = ChannelSupSupPid,
+ start_heartbeat_fun = SHF,
+ buf = Buf,
+ buf_len = BufLen}) ->
+ {Parent, Sock, RecvLen, PendingRecv, QueueCollector,
+ ChannelSupSupPid, SHF, Buf, BufLen}.