summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rabbit_framing_channel.erl29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/rabbit_framing_channel.erl b/src/rabbit_framing_channel.erl
index 6739b3d6f8..333604c835 100644
--- a/src/rabbit_framing_channel.erl
+++ b/src/rabbit_framing_channel.erl
@@ -73,16 +73,25 @@ read_frame(ChannelPid) ->
end.
mainloop(ChannelPid, Protocol) ->
- {method, MethodName, FieldsBin} = read_frame(ChannelPid),
- Method = Protocol:decode_method_fields(MethodName, FieldsBin),
- case Protocol:method_has_content(MethodName) of
- true -> {ClassId, _MethodId} = Protocol:method_id(MethodName),
- rabbit_channel:do(ChannelPid, Method,
- collect_content(ChannelPid, ClassId,
- Protocol));
- false -> rabbit_channel:do(ChannelPid, Method)
- end,
- ?MODULE:mainloop(ChannelPid, Protocol).
+ Decoded = read_frame(ChannelPid),
+ case Decoded of
+ {method, MethodName, FieldsBin} ->
+ Method = Protocol:decode_method_fields(MethodName, FieldsBin),
+ case Protocol:method_has_content(MethodName) of
+ true -> {ClassId, _MethodId} = Protocol:method_id(MethodName),
+ rabbit_channel:do(ChannelPid, Method,
+ collect_content(ChannelPid,
+ ClassId,
+ Protocol));
+ false -> rabbit_channel:do(ChannelPid, Method)
+ end,
+ ?MODULE:mainloop(ChannelPid, Protocol);
+ _ ->
+ rabbit_misc:protocol_error(
+ unexpected_frame,
+ "expected method frame, got ~p instead",
+ [Decoded])
+ end.
collect_content(ChannelPid, ClassId, Protocol) ->
case read_frame(ChannelPid) of