summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2010-06-15 18:20:37 +0100
committerSimon MacMullen <simon@rabbitmq.com>2010-06-15 18:20:37 +0100
commit17cc6a4240ccf9cadf5e5444a406c3f2dae26098 (patch)
tree0f0c49447f308439ba27656bce7dbf2c2a606a23
parent2ca2876a06926d0dc4da27486ef7b3d122fd9f05 (diff)
downloadrabbitmq-server-bug21835.tar.gz
Send unexpected_frame if we get the wrong frame type or mismatched class ids.bug21835
-rw-r--r--src/rabbit_framing_channel.erl31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/rabbit_framing_channel.erl b/src/rabbit_framing_channel.erl
index b7c6aa96..161dfd84 100644
--- a/src/rabbit_framing_channel.erl
+++ b/src/rabbit_framing_channel.erl
@@ -73,14 +73,23 @@ read_frame(ChannelPid) ->
end.
mainloop(ChannelPid) ->
- {method, MethodName, FieldsBin} = read_frame(ChannelPid),
- Method = rabbit_framing:decode_method_fields(MethodName, FieldsBin),
- case rabbit_framing:method_has_content(MethodName) of
- true -> rabbit_channel:do(ChannelPid, Method,
- collect_content(ChannelPid, MethodName));
- false -> rabbit_channel:do(ChannelPid, Method)
- end,
- ?MODULE:mainloop(ChannelPid).
+ Decoded = read_frame(ChannelPid),
+ case Decoded of
+ {method, MethodName, FieldsBin} ->
+ Method = rabbit_framing:decode_method_fields(MethodName, FieldsBin),
+ case rabbit_framing:method_has_content(MethodName) of
+ true -> rabbit_channel:do(ChannelPid, Method,
+ collect_content(ChannelPid,
+ MethodName));
+ false -> rabbit_channel:do(ChannelPid, Method)
+ end,
+ ?MODULE:mainloop(ChannelPid);
+ _ ->
+ rabbit_misc:protocol_error(
+ unexpected_frame,
+ "expected method frame, got ~p instead",
+ [Decoded])
+ end.
collect_content(ChannelPid, MethodName) ->
{ClassId, _MethodId} = rabbit_framing:method_id(MethodName),
@@ -94,14 +103,14 @@ collect_content(ChannelPid, MethodName) ->
payload_fragments_rev = Payload};
true ->
rabbit_misc:protocol_error(
- command_invalid,
+ unexpected_frame,
"expected content header for class ~w, "
"got one for class ~w instead",
[ClassId, HeaderClassId])
end;
_ ->
rabbit_misc:protocol_error(
- command_invalid,
+ unexpected_frame,
"expected content header for class ~w, "
"got non content header frame instead",
[ClassId])
@@ -117,7 +126,7 @@ collect_content_payload(ChannelPid, RemainingByteCount, Acc) ->
[FragmentBin | Acc]);
_ ->
rabbit_misc:protocol_error(
- command_invalid,
+ unexpected_frame,
"expected content body, got non content body frame instead",
[])
end.